<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<HTML>
<HEAD>
<LINK REL=STYLESHEET TYPE="text/css" HREF="../stylesheet.css" TITLE="Style">
<META NAME="GENERATOR" CONTENT="Java2HTML Version 1.5">
<TITLE>jminusminus.Parser (Java2HTML)</TITLE>
</HEAD>
<BODY><TABLE id="Header" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td colspan="2" width="33%">&nbsp;</td>
<td align="center" colspan="2" width="33%">
<font size="4">Parser.java</font>
</td>
<td align="right" colspan="2" width="33%">&nbsp;</td>
</tr>
</TABLE>
<pre ID="Classes">
<FONT ID="LN">1   </FONT><A NAME="1"></A><FONT ID="SingleLineComment">// Copyright 2013 Bill Campbell, Swami Iyer and Bahar Akbal-Delibas
<FONT ID="LN">2   </FONT><A NAME="2"></A></FONT>
<FONT ID="LN">3   </FONT><A NAME="3"></A><FONT ID="Package">package</FONT> jminusminus;
<FONT ID="LN">4   </FONT><A NAME="4"></A>
<FONT ID="LN">5   </FONT><A NAME="5"></A><FONT ID="Import">import</FONT> java.util.ArrayList;
<FONT ID="LN">6   </FONT><A NAME="6"></A><FONT ID="Import">import</FONT> <FONT ID="Static">static</FONT> jminusminus.TokenKind.*;
<FONT ID="LN">7   </FONT><A NAME="7"></A>
<FONT ID="LN">8   </FONT><A NAME="8"></A><FONT ID="FormalComment">/**
<FONT ID="LN">9   </FONT><A NAME="9"></A> * A recursive descent parser that, given a lexical analyzer (a
<FONT ID="LN">10  </FONT><A NAME="10"></A> * LookaheadScanner), parses a Java compilation unit (program file), taking
<FONT ID="LN">11  </FONT><A NAME="11"></A> * tokens from the LookaheadScanner, and produces an abstract syntax tree (AST)
<FONT ID="LN">12  </FONT><A NAME="12"></A> * for it.
<FONT ID="LN">13  </FONT><A NAME="13"></A> */</FONT>
<FONT ID="LN">14  </FONT><A NAME="14"></A>
<FONT ID="LN">15  </FONT><A NAME="15"></A><FONT ID="Public">public</FONT> <FONT ID="Class">class</FONT> Parser {
<FONT ID="LN">16  </FONT><A NAME="16"></A>
<FONT ID="LN">17  </FONT><A NAME="17"></A>    <FONT ID="FormalComment">/** The lexical analyzer with which tokens are scanned. */</FONT>
<FONT ID="LN">18  </FONT><A NAME="18"></A>    <FONT ID="Private">private</FONT> <A HREF="../jminusminus/LookaheadScanner.java.html">LookaheadScanner</A> scanner;
<FONT ID="LN">19  </FONT><A NAME="19"></A>
<FONT ID="LN">20  </FONT><A NAME="20"></A>    <FONT ID="FormalComment">/** Whether a parser error has been found. */</FONT>
<FONT ID="LN">21  </FONT><A NAME="21"></A>    <FONT ID="Private">private</FONT> <FONT ID="Boolean">boolean</FONT> isInError;
<FONT ID="LN">22  </FONT><A NAME="22"></A>
<FONT ID="LN">23  </FONT><A NAME="23"></A>    <FONT ID="FormalComment">/** Wheter we have recovered from a parser error. */</FONT>
<FONT ID="LN">24  </FONT><A NAME="24"></A>    <FONT ID="Private">private</FONT> <FONT ID="Boolean">boolean</FONT> isRecovered;
<FONT ID="LN">25  </FONT><A NAME="25"></A>
<FONT ID="LN">26  </FONT><A NAME="26"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">27  </FONT><A NAME="27"></A>     * Construct a parser from the given lexical analyzer.
<FONT ID="LN">28  </FONT><A NAME="28"></A>     * 
<FONT ID="LN">29  </FONT><A NAME="29"></A>     * @param scanner
<FONT ID="LN">30  </FONT><A NAME="30"></A>     *            the lexical analyzer with which tokens are scanned.
<FONT ID="LN">31  </FONT><A NAME="31"></A>     */</FONT>
<FONT ID="LN">32  </FONT><A NAME="32"></A>
<FONT ID="LN">33  </FONT><A NAME="33"></A>    <FONT ID="Public">public</FONT> Parser(<A HREF="../jminusminus/LookaheadScanner.java.html">LookaheadScanner</A> scanner) {
<FONT ID="LN">34  </FONT><A NAME="34"></A>        <FONT ID="This">this</FONT>.scanner = scanner;
<FONT ID="LN">35  </FONT><A NAME="35"></A>        isInError = <FONT ID="False">false</FONT>;
<FONT ID="LN">36  </FONT><A NAME="36"></A>        isRecovered = <FONT ID="True">true</FONT>;
<FONT ID="LN">37  </FONT><A NAME="37"></A>        scanner.next(); <FONT ID="SingleLineComment">// Prime the pump
<FONT ID="LN">38  </FONT><A NAME="38"></A></FONT>    }
<FONT ID="LN">39  </FONT><A NAME="39"></A>
<FONT ID="LN">40  </FONT><A NAME="40"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">41  </FONT><A NAME="41"></A>     * Has a parser error occurred up to now?
<FONT ID="LN">42  </FONT><A NAME="42"></A>     * 
<FONT ID="LN">43  </FONT><A NAME="43"></A>     * @return true or false.
<FONT ID="LN">44  </FONT><A NAME="44"></A>     */</FONT>
<FONT ID="LN">45  </FONT><A NAME="45"></A>
<FONT ID="LN">46  </FONT><A NAME="46"></A>    <FONT ID="Public">public</FONT> <FONT ID="Boolean">boolean</FONT> errorHasOccurred() {
<FONT ID="LN">47  </FONT><A NAME="47"></A>        <FONT ID="Return">return</FONT> isInError;
<FONT ID="LN">48  </FONT><A NAME="48"></A>    }
<FONT ID="LN">49  </FONT><A NAME="49"></A>
<FONT ID="LN">50  </FONT><A NAME="50"></A>    <FONT ID="SingleLineComment">// ////////////////////////////////////////////////
<FONT ID="LN">51  </FONT><A NAME="51"></A></FONT>    <FONT ID="SingleLineComment">// Parsing Support ///////////////////////////////
<FONT ID="LN">52  </FONT><A NAME="52"></A></FONT>    <FONT ID="SingleLineComment">// ////////////////////////////////////////////////
<FONT ID="LN">53  </FONT><A NAME="53"></A></FONT>
<FONT ID="LN">54  </FONT><A NAME="54"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">55  </FONT><A NAME="55"></A>     * Is the current token this one?
<FONT ID="LN">56  </FONT><A NAME="56"></A>     * 
<FONT ID="LN">57  </FONT><A NAME="57"></A>     * @param sought
<FONT ID="LN">58  </FONT><A NAME="58"></A>     *            the token we're looking for.
<FONT ID="LN">59  </FONT><A NAME="59"></A>     * @return true iff they match; false otherwise.
<FONT ID="LN">60  </FONT><A NAME="60"></A>     */</FONT>
<FONT ID="LN">61  </FONT><A NAME="61"></A>
<FONT ID="LN">62  </FONT><A NAME="62"></A>    <FONT ID="Private">private</FONT> <FONT ID="Boolean">boolean</FONT> see(TokenKind sought) {
<FONT ID="LN">63  </FONT><A NAME="63"></A>        <FONT ID="Return">return</FONT> (sought == scanner.token().kind());
<FONT ID="LN">64  </FONT><A NAME="64"></A>    }
<FONT ID="LN">65  </FONT><A NAME="65"></A>
<FONT ID="LN">66  </FONT><A NAME="66"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">67  </FONT><A NAME="67"></A>     * Look at the current (unscanned) token to see if it's one we're looking
<FONT ID="LN">68  </FONT><A NAME="68"></A>     * for. If so, scan it and return true; otherwise return false (without
<FONT ID="LN">69  </FONT><A NAME="69"></A>     * scanning a thing).
<FONT ID="LN">70  </FONT><A NAME="70"></A>     * 
<FONT ID="LN">71  </FONT><A NAME="71"></A>     * @param sought
<FONT ID="LN">72  </FONT><A NAME="72"></A>     *            the token we're looking for.
<FONT ID="LN">73  </FONT><A NAME="73"></A>     * @return true iff they match; false otherwise.
<FONT ID="LN">74  </FONT><A NAME="74"></A>     */</FONT>
<FONT ID="LN">75  </FONT><A NAME="75"></A>
<FONT ID="LN">76  </FONT><A NAME="76"></A>    <FONT ID="Private">private</FONT> <FONT ID="Boolean">boolean</FONT> have(TokenKind sought) {
<FONT ID="LN">77  </FONT><A NAME="77"></A>        <FONT ID="If">if</FONT> (see(sought)) {
<FONT ID="LN">78  </FONT><A NAME="78"></A>            scanner.next();
<FONT ID="LN">79  </FONT><A NAME="79"></A>            <FONT ID="Return">return</FONT> <FONT ID="True">true</FONT>;
<FONT ID="LN">80  </FONT><A NAME="80"></A>        } <FONT ID="Else">else</FONT> {
<FONT ID="LN">81  </FONT><A NAME="81"></A>            <FONT ID="Return">return</FONT> <FONT ID="False">false</FONT>;
<FONT ID="LN">82  </FONT><A NAME="82"></A>        }
<FONT ID="LN">83  </FONT><A NAME="83"></A>    }
<FONT ID="LN">84  </FONT><A NAME="84"></A>
<FONT ID="LN">85  </FONT><A NAME="85"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">86  </FONT><A NAME="86"></A>     * Attempt to match a token we're looking for with the current input token.
<FONT ID="LN">87  </FONT><A NAME="87"></A>     * If we succeed, scan the token and go into a "isRecovered" state. If we
<FONT ID="LN">88  </FONT><A NAME="88"></A>     * fail, then what we do next depends on whether or not we're currently in a
<FONT ID="LN">89  </FONT><A NAME="89"></A>     * "isRecovered" state: if so, we report the error and go into an
<FONT ID="LN">90  </FONT><A NAME="90"></A>     * "Unrecovered" state; if not, we repeatedly scan tokens until we find the
<FONT ID="LN">91  </FONT><A NAME="91"></A>     * one we're looking for (or EOF) and then return to a "isRecovered" state.
<FONT ID="LN">92  </FONT><A NAME="92"></A>     * This gives us a kind of poor man's syntactic error recovery. The strategy
<FONT ID="LN">93  </FONT><A NAME="93"></A>     * is due to David Turner and Ron Morrison.
<FONT ID="LN">94  </FONT><A NAME="94"></A>     * 
<FONT ID="LN">95  </FONT><A NAME="95"></A>     * @param sought
<FONT ID="LN">96  </FONT><A NAME="96"></A>     *            the token we're looking for.
<FONT ID="LN">97  </FONT><A NAME="97"></A>     */</FONT>
<FONT ID="LN">98  </FONT><A NAME="98"></A>
<FONT ID="LN">99  </FONT><A NAME="99"></A>    <FONT ID="Private">private</FONT> <FONT ID="Void">void</FONT> mustBe(TokenKind sought) {
<FONT ID="LN">100 </FONT><A NAME="100"></A>        <FONT ID="If">if</FONT> (scanner.token().kind() == sought) {
<FONT ID="LN">101 </FONT><A NAME="101"></A>            scanner.next();
<FONT ID="LN">102 </FONT><A NAME="102"></A>            isRecovered = <FONT ID="True">true</FONT>;
<FONT ID="LN">103 </FONT><A NAME="103"></A>        } <FONT ID="Else">else</FONT> <FONT ID="If">if</FONT> (isRecovered) {
<FONT ID="LN">104 </FONT><A NAME="104"></A>            isRecovered = <FONT ID="False">false</FONT>;
<FONT ID="LN">105 </FONT><A NAME="105"></A>            reportParserError(<FONT ID="StringLiteral">"%s found where %s sought"</FONT>, scanner.token()
<FONT ID="LN">106 </FONT><A NAME="106"></A>                    .image(), sought.image());
<FONT ID="LN">107 </FONT><A NAME="107"></A>        } <FONT ID="Else">else</FONT> {
<FONT ID="LN">108 </FONT><A NAME="108"></A>            <FONT ID="SingleLineComment">// Do not report the (possibly spurious) error,
<FONT ID="LN">109 </FONT><A NAME="109"></A></FONT>            <FONT ID="SingleLineComment">// but rather attempt to recover by forcing a match.
<FONT ID="LN">110 </FONT><A NAME="110"></A></FONT>            <FONT ID="While">while</FONT> (!see(sought) &amp;&amp; !see(EOF)) {
<FONT ID="LN">111 </FONT><A NAME="111"></A>                scanner.next();
<FONT ID="LN">112 </FONT><A NAME="112"></A>            }
<FONT ID="LN">113 </FONT><A NAME="113"></A>            <FONT ID="If">if</FONT> (see(sought)) {
<FONT ID="LN">114 </FONT><A NAME="114"></A>                scanner.next();
<FONT ID="LN">115 </FONT><A NAME="115"></A>                isRecovered = <FONT ID="True">true</FONT>;
<FONT ID="LN">116 </FONT><A NAME="116"></A>            }
<FONT ID="LN">117 </FONT><A NAME="117"></A>        }
<FONT ID="LN">118 </FONT><A NAME="118"></A>    }
<FONT ID="LN">119 </FONT><A NAME="119"></A>
<FONT ID="LN">120 </FONT><A NAME="120"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">121 </FONT><A NAME="121"></A>     * Pull out the ambiguous part of a name and return it.
<FONT ID="LN">122 </FONT><A NAME="122"></A>     * 
<FONT ID="LN">123 </FONT><A NAME="123"></A>     * @param name
<FONT ID="LN">124 </FONT><A NAME="124"></A>     *            with an ambiguos part (possibly).
<FONT ID="LN">125 </FONT><A NAME="125"></A>     * @return ambiguous part or null.
<FONT ID="LN">126 </FONT><A NAME="126"></A>     */</FONT>
<FONT ID="LN">127 </FONT><A NAME="127"></A>
<FONT ID="LN">128 </FONT><A NAME="128"></A>    <FONT ID="Private">private</FONT> <A HREF="../jminusminus/AmbiguousName.java.html">AmbiguousName</A> ambiguousPart(TypeName name) {
<FONT ID="LN">129 </FONT><A NAME="129"></A>        String qualifiedName = name.toString();
<FONT ID="LN">130 </FONT><A NAME="130"></A>        <FONT ID="Int">int</FONT> lastDotIndex = qualifiedName.lastIndexOf(<FONT ID="CharacerLiteral">'.'</FONT>);
<FONT ID="LN">131 </FONT><A NAME="131"></A>        <FONT ID="Return">return</FONT> lastDotIndex == -<FONT ID="IntegerLiteral">1</FONT> ? <FONT ID="Null">null</FONT> <FONT ID="SingleLineComment">// It was a simple
<FONT ID="LN">132 </FONT><A NAME="132"></A></FONT>                <FONT ID="SingleLineComment">// name
<FONT ID="LN">133 </FONT><A NAME="133"></A></FONT>                : <FONT ID="New">new</FONT> <A HREF="../jminusminus/AmbiguousName.java.html">AmbiguousName</A>(name.line(), qualifiedName.substring(<FONT ID="IntegerLiteral">0</FONT>,
<FONT ID="LN">134 </FONT><A NAME="134"></A>                        lastDotIndex));
<FONT ID="LN">135 </FONT><A NAME="135"></A>    }
<FONT ID="LN">136 </FONT><A NAME="136"></A>
<FONT ID="LN">137 </FONT><A NAME="137"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">138 </FONT><A NAME="138"></A>     * Report a syntax error.
<FONT ID="LN">139 </FONT><A NAME="139"></A>     * 
<FONT ID="LN">140 </FONT><A NAME="140"></A>     * @param message
<FONT ID="LN">141 </FONT><A NAME="141"></A>     *            message identifying the error.
<FONT ID="LN">142 </FONT><A NAME="142"></A>     * @param args
<FONT ID="LN">143 </FONT><A NAME="143"></A>     *            related values.
<FONT ID="LN">144 </FONT><A NAME="144"></A>     */</FONT>
<FONT ID="LN">145 </FONT><A NAME="145"></A>
<FONT ID="LN">146 </FONT><A NAME="146"></A>    <FONT ID="Private">private</FONT> <FONT ID="Void">void</FONT> reportParserError(String message, Object... args) {
<FONT ID="LN">147 </FONT><A NAME="147"></A>        isInError = <FONT ID="True">true</FONT>;
<FONT ID="LN">148 </FONT><A NAME="148"></A>        isRecovered = <FONT ID="False">false</FONT>;
<FONT ID="LN">149 </FONT><A NAME="149"></A>        System.err
<FONT ID="LN">150 </FONT><A NAME="150"></A>                .printf(<FONT ID="StringLiteral">"%s:%d: "</FONT>, scanner.fileName(), scanner.token().line());
<FONT ID="LN">151 </FONT><A NAME="151"></A>        System.err.printf(message, args);
<FONT ID="LN">152 </FONT><A NAME="152"></A>        System.err.println();
<FONT ID="LN">153 </FONT><A NAME="153"></A>    }
<FONT ID="LN">154 </FONT><A NAME="154"></A>
<FONT ID="LN">155 </FONT><A NAME="155"></A>    <FONT ID="SingleLineComment">// ////////////////////////////////////////////////
<FONT ID="LN">156 </FONT><A NAME="156"></A></FONT>    <FONT ID="SingleLineComment">// Lookahead /////////////////////////////////////
<FONT ID="LN">157 </FONT><A NAME="157"></A></FONT>    <FONT ID="SingleLineComment">// ////////////////////////////////////////////////
<FONT ID="LN">158 </FONT><A NAME="158"></A></FONT>
<FONT ID="LN">159 </FONT><A NAME="159"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">160 </FONT><A NAME="160"></A>     * Are we looking at an IDENTIFIER followed by a LPAREN? Look ahead to find
<FONT ID="LN">161 </FONT><A NAME="161"></A>     * out.
<FONT ID="LN">162 </FONT><A NAME="162"></A>     * 
<FONT ID="LN">163 </FONT><A NAME="163"></A>     * @return true iff we're looking at IDENTIFIER LPAREN; false otherwise.
<FONT ID="LN">164 </FONT><A NAME="164"></A>     */</FONT>
<FONT ID="LN">165 </FONT><A NAME="165"></A>
<FONT ID="LN">166 </FONT><A NAME="166"></A>    <FONT ID="Private">private</FONT> <FONT ID="Boolean">boolean</FONT> seeIdentLParen() {
<FONT ID="LN">167 </FONT><A NAME="167"></A>        scanner.recordPosition();
<FONT ID="LN">168 </FONT><A NAME="168"></A>        <FONT ID="Boolean">boolean</FONT> result = have(IDENTIFIER) &amp;&amp; see(LPAREN);
<FONT ID="LN">169 </FONT><A NAME="169"></A>        scanner.returnToPosition();
<FONT ID="LN">170 </FONT><A NAME="170"></A>        <FONT ID="Return">return</FONT> result;
<FONT ID="LN">171 </FONT><A NAME="171"></A>    }
<FONT ID="LN">172 </FONT><A NAME="172"></A>
<FONT ID="LN">173 </FONT><A NAME="173"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">174 </FONT><A NAME="174"></A>     * Are we looking at a cast? ie.
<FONT ID="LN">175 </FONT><A NAME="175"></A>     * 
<FONT ID="LN">176 </FONT><A NAME="176"></A>     * &lt;pre&gt;
<FONT ID="LN">177 </FONT><A NAME="177"></A>     *   LPAREN type RPAREN ...
<FONT ID="LN">178 </FONT><A NAME="178"></A>     * &lt;/pre&gt;
<FONT ID="LN">179 </FONT><A NAME="179"></A>     * 
<FONT ID="LN">180 </FONT><A NAME="180"></A>     * Look ahead to find out.
<FONT ID="LN">181 </FONT><A NAME="181"></A>     * 
<FONT ID="LN">182 </FONT><A NAME="182"></A>     * @return true iff we're looking at a cast; false otherwise.
<FONT ID="LN">183 </FONT><A NAME="183"></A>     */</FONT>
<FONT ID="LN">184 </FONT><A NAME="184"></A>
<FONT ID="LN">185 </FONT><A NAME="185"></A>    <FONT ID="Private">private</FONT> <FONT ID="Boolean">boolean</FONT> seeCast() {
<FONT ID="LN">186 </FONT><A NAME="186"></A>        scanner.recordPosition();
<FONT ID="LN">187 </FONT><A NAME="187"></A>        <FONT ID="If">if</FONT> (!have(LPAREN)) {
<FONT ID="LN">188 </FONT><A NAME="188"></A>            scanner.returnToPosition();
<FONT ID="LN">189 </FONT><A NAME="189"></A>            <FONT ID="Return">return</FONT> <FONT ID="False">false</FONT>;
<FONT ID="LN">190 </FONT><A NAME="190"></A>        }
<FONT ID="LN">191 </FONT><A NAME="191"></A>        <FONT ID="If">if</FONT> (seeBasicType()) {
<FONT ID="LN">192 </FONT><A NAME="192"></A>            scanner.returnToPosition();
<FONT ID="LN">193 </FONT><A NAME="193"></A>            <FONT ID="Return">return</FONT> <FONT ID="True">true</FONT>;
<FONT ID="LN">194 </FONT><A NAME="194"></A>        }
<FONT ID="LN">195 </FONT><A NAME="195"></A>        <FONT ID="If">if</FONT> (!see(IDENTIFIER)) {
<FONT ID="LN">196 </FONT><A NAME="196"></A>            scanner.returnToPosition();
<FONT ID="LN">197 </FONT><A NAME="197"></A>            <FONT ID="Return">return</FONT> <FONT ID="False">false</FONT>;
<FONT ID="LN">198 </FONT><A NAME="198"></A>        } <FONT ID="Else">else</FONT> {
<FONT ID="LN">199 </FONT><A NAME="199"></A>            scanner.next(); <FONT ID="SingleLineComment">// Scan the IDENTIFIER
<FONT ID="LN">200 </FONT><A NAME="200"></A></FONT>            <FONT ID="SingleLineComment">// A qualified identifier is ok
<FONT ID="LN">201 </FONT><A NAME="201"></A></FONT>            <FONT ID="While">while</FONT> (have(DOT)) {
<FONT ID="LN">202 </FONT><A NAME="202"></A>                <FONT ID="If">if</FONT> (!have(IDENTIFIER)) {
<FONT ID="LN">203 </FONT><A NAME="203"></A>                    scanner.returnToPosition();
<FONT ID="LN">204 </FONT><A NAME="204"></A>                    <FONT ID="Return">return</FONT> <FONT ID="False">false</FONT>;
<FONT ID="LN">205 </FONT><A NAME="205"></A>                }
<FONT ID="LN">206 </FONT><A NAME="206"></A>            }
<FONT ID="LN">207 </FONT><A NAME="207"></A>        }
<FONT ID="LN">208 </FONT><A NAME="208"></A>        <FONT ID="While">while</FONT> (have(LBRACK)) {
<FONT ID="LN">209 </FONT><A NAME="209"></A>            <FONT ID="If">if</FONT> (!have(RBRACK)) {
<FONT ID="LN">210 </FONT><A NAME="210"></A>                scanner.returnToPosition();
<FONT ID="LN">211 </FONT><A NAME="211"></A>                <FONT ID="Return">return</FONT> <FONT ID="False">false</FONT>;
<FONT ID="LN">212 </FONT><A NAME="212"></A>            }
<FONT ID="LN">213 </FONT><A NAME="213"></A>        }
<FONT ID="LN">214 </FONT><A NAME="214"></A>        <FONT ID="If">if</FONT> (!have(RPAREN)) {
<FONT ID="LN">215 </FONT><A NAME="215"></A>            scanner.returnToPosition();
<FONT ID="LN">216 </FONT><A NAME="216"></A>            <FONT ID="Return">return</FONT> <FONT ID="False">false</FONT>;
<FONT ID="LN">217 </FONT><A NAME="217"></A>        }
<FONT ID="LN">218 </FONT><A NAME="218"></A>        scanner.returnToPosition();
<FONT ID="LN">219 </FONT><A NAME="219"></A>        <FONT ID="Return">return</FONT> <FONT ID="True">true</FONT>;
<FONT ID="LN">220 </FONT><A NAME="220"></A>    }
<FONT ID="LN">221 </FONT><A NAME="221"></A>
<FONT ID="LN">222 </FONT><A NAME="222"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">223 </FONT><A NAME="223"></A>     * Are we looking at a local variable declaration? ie.
<FONT ID="LN">224 </FONT><A NAME="224"></A>     * 
<FONT ID="LN">225 </FONT><A NAME="225"></A>     * &lt;pre&gt;
<FONT ID="LN">226 </FONT><A NAME="226"></A>     *   type IDENTIFIER {LBRACK RBRACK} ...
<FONT ID="LN">227 </FONT><A NAME="227"></A>     * &lt;/pre&gt;
<FONT ID="LN">228 </FONT><A NAME="228"></A>     * 
<FONT ID="LN">229 </FONT><A NAME="229"></A>     * Look ahead to determine.
<FONT ID="LN">230 </FONT><A NAME="230"></A>     * 
<FONT ID="LN">231 </FONT><A NAME="231"></A>     * @return true iff we are looking at local variable declaration; false
<FONT ID="LN">232 </FONT><A NAME="232"></A>     *         otherwise.
<FONT ID="LN">233 </FONT><A NAME="233"></A>     */</FONT>
<FONT ID="LN">234 </FONT><A NAME="234"></A>
<FONT ID="LN">235 </FONT><A NAME="235"></A>    <FONT ID="Private">private</FONT> <FONT ID="Boolean">boolean</FONT> seeLocalVariableDeclaration() {
<FONT ID="LN">236 </FONT><A NAME="236"></A>        scanner.recordPosition();
<FONT ID="LN">237 </FONT><A NAME="237"></A>        <FONT ID="If">if</FONT> (have(IDENTIFIER)) {
<FONT ID="LN">238 </FONT><A NAME="238"></A>            <FONT ID="SingleLineComment">// A qualified identifier is ok
<FONT ID="LN">239 </FONT><A NAME="239"></A></FONT>            <FONT ID="While">while</FONT> (have(DOT)) {
<FONT ID="LN">240 </FONT><A NAME="240"></A>                <FONT ID="If">if</FONT> (!have(IDENTIFIER)) {
<FONT ID="LN">241 </FONT><A NAME="241"></A>                    scanner.returnToPosition();
<FONT ID="LN">242 </FONT><A NAME="242"></A>                    <FONT ID="Return">return</FONT> <FONT ID="False">false</FONT>;
<FONT ID="LN">243 </FONT><A NAME="243"></A>                }
<FONT ID="LN">244 </FONT><A NAME="244"></A>            }
<FONT ID="LN">245 </FONT><A NAME="245"></A>        } <FONT ID="Else">else</FONT> <FONT ID="If">if</FONT> (seeBasicType()) {
<FONT ID="LN">246 </FONT><A NAME="246"></A>            scanner.next();
<FONT ID="LN">247 </FONT><A NAME="247"></A>        } <FONT ID="Else">else</FONT> {
<FONT ID="LN">248 </FONT><A NAME="248"></A>            scanner.returnToPosition();
<FONT ID="LN">249 </FONT><A NAME="249"></A>            <FONT ID="Return">return</FONT> <FONT ID="False">false</FONT>;
<FONT ID="LN">250 </FONT><A NAME="250"></A>        }
<FONT ID="LN">251 </FONT><A NAME="251"></A>        <FONT ID="While">while</FONT> (have(LBRACK)) {
<FONT ID="LN">252 </FONT><A NAME="252"></A>            <FONT ID="If">if</FONT> (!have(RBRACK)) {
<FONT ID="LN">253 </FONT><A NAME="253"></A>                scanner.returnToPosition();
<FONT ID="LN">254 </FONT><A NAME="254"></A>                <FONT ID="Return">return</FONT> <FONT ID="False">false</FONT>;
<FONT ID="LN">255 </FONT><A NAME="255"></A>            }
<FONT ID="LN">256 </FONT><A NAME="256"></A>        }
<FONT ID="LN">257 </FONT><A NAME="257"></A>        <FONT ID="If">if</FONT> (!have(IDENTIFIER)) {
<FONT ID="LN">258 </FONT><A NAME="258"></A>            scanner.returnToPosition();
<FONT ID="LN">259 </FONT><A NAME="259"></A>            <FONT ID="Return">return</FONT> <FONT ID="False">false</FONT>;
<FONT ID="LN">260 </FONT><A NAME="260"></A>        }
<FONT ID="LN">261 </FONT><A NAME="261"></A>        <FONT ID="While">while</FONT> (have(LBRACK)) {
<FONT ID="LN">262 </FONT><A NAME="262"></A>            <FONT ID="If">if</FONT> (!have(RBRACK)) {
<FONT ID="LN">263 </FONT><A NAME="263"></A>                scanner.returnToPosition();
<FONT ID="LN">264 </FONT><A NAME="264"></A>                <FONT ID="Return">return</FONT> <FONT ID="False">false</FONT>;
<FONT ID="LN">265 </FONT><A NAME="265"></A>            }
<FONT ID="LN">266 </FONT><A NAME="266"></A>        }
<FONT ID="LN">267 </FONT><A NAME="267"></A>        scanner.returnToPosition();
<FONT ID="LN">268 </FONT><A NAME="268"></A>        <FONT ID="Return">return</FONT> <FONT ID="True">true</FONT>;
<FONT ID="LN">269 </FONT><A NAME="269"></A>    }
<FONT ID="LN">270 </FONT><A NAME="270"></A>
<FONT ID="LN">271 </FONT><A NAME="271"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">272 </FONT><A NAME="272"></A>     * Are we looking at a basic type? ie.
<FONT ID="LN">273 </FONT><A NAME="273"></A>     * 
<FONT ID="LN">274 </FONT><A NAME="274"></A>     * &lt;pre&gt;
<FONT ID="LN">275 </FONT><A NAME="275"></A>     * BOOLEAN | CHAR | INT
<FONT ID="LN">276 </FONT><A NAME="276"></A>     * &lt;/pre&gt;
<FONT ID="LN">277 </FONT><A NAME="277"></A>     * 
<FONT ID="LN">278 </FONT><A NAME="278"></A>     * @return true iff we're looking at a basic type; false otherwise.
<FONT ID="LN">279 </FONT><A NAME="279"></A>     */</FONT>
<FONT ID="LN">280 </FONT><A NAME="280"></A>
<FONT ID="LN">281 </FONT><A NAME="281"></A>    <FONT ID="Private">private</FONT> <FONT ID="Boolean">boolean</FONT> seeBasicType() {
<FONT ID="LN">282 </FONT><A NAME="282"></A>        <FONT ID="If">if</FONT> (see(BOOLEAN) || see(CHAR) || see(INT)) {
<FONT ID="LN">283 </FONT><A NAME="283"></A>            <FONT ID="Return">return</FONT> <FONT ID="True">true</FONT>;
<FONT ID="LN">284 </FONT><A NAME="284"></A>        } <FONT ID="Else">else</FONT> {
<FONT ID="LN">285 </FONT><A NAME="285"></A>            <FONT ID="Return">return</FONT> <FONT ID="False">false</FONT>;
<FONT ID="LN">286 </FONT><A NAME="286"></A>        }
<FONT ID="LN">287 </FONT><A NAME="287"></A>    }
<FONT ID="LN">288 </FONT><A NAME="288"></A>
<FONT ID="LN">289 </FONT><A NAME="289"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">290 </FONT><A NAME="290"></A>     * Are we looking at a reference type? ie.
<FONT ID="LN">291 </FONT><A NAME="291"></A>     * 
<FONT ID="LN">292 </FONT><A NAME="292"></A>     * &lt;pre&gt;
<FONT ID="LN">293 </FONT><A NAME="293"></A>     *   referenceType ::= basicType LBRACK RBRACK {LBRACK RBRACK}
<FONT ID="LN">294 </FONT><A NAME="294"></A>     *                   | qualifiedIdentifier {LBRACK RBRACK}
<FONT ID="LN">295 </FONT><A NAME="295"></A>     * &lt;/pre&gt;
<FONT ID="LN">296 </FONT><A NAME="296"></A>     * 
<FONT ID="LN">297 </FONT><A NAME="297"></A>     * @return true iff we're looking at a reference type; false otherwise.
<FONT ID="LN">298 </FONT><A NAME="298"></A>     */</FONT>
<FONT ID="LN">299 </FONT><A NAME="299"></A>
<FONT ID="LN">300 </FONT><A NAME="300"></A>    <FONT ID="Private">private</FONT> <FONT ID="Boolean">boolean</FONT> seeReferenceType() {
<FONT ID="LN">301 </FONT><A NAME="301"></A>        <FONT ID="If">if</FONT> (see(IDENTIFIER)) {
<FONT ID="LN">302 </FONT><A NAME="302"></A>            <FONT ID="Return">return</FONT> <FONT ID="True">true</FONT>;
<FONT ID="LN">303 </FONT><A NAME="303"></A>        } <FONT ID="Else">else</FONT> {
<FONT ID="LN">304 </FONT><A NAME="304"></A>            scanner.recordPosition();
<FONT ID="LN">305 </FONT><A NAME="305"></A>            <FONT ID="If">if</FONT> (have(BOOLEAN) || have(CHAR) || have(INT)) {
<FONT ID="LN">306 </FONT><A NAME="306"></A>                <FONT ID="If">if</FONT> (have(LBRACK) &amp;&amp; see(RBRACK)) {
<FONT ID="LN">307 </FONT><A NAME="307"></A>                    scanner.returnToPosition();
<FONT ID="LN">308 </FONT><A NAME="308"></A>                    <FONT ID="Return">return</FONT> <FONT ID="True">true</FONT>;
<FONT ID="LN">309 </FONT><A NAME="309"></A>                }
<FONT ID="LN">310 </FONT><A NAME="310"></A>            }
<FONT ID="LN">311 </FONT><A NAME="311"></A>            scanner.returnToPosition();
<FONT ID="LN">312 </FONT><A NAME="312"></A>        }
<FONT ID="LN">313 </FONT><A NAME="313"></A>        <FONT ID="Return">return</FONT> <FONT ID="False">false</FONT>;
<FONT ID="LN">314 </FONT><A NAME="314"></A>    }
<FONT ID="LN">315 </FONT><A NAME="315"></A>
<FONT ID="LN">316 </FONT><A NAME="316"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">317 </FONT><A NAME="317"></A>     * Are we looking at []?
<FONT ID="LN">318 </FONT><A NAME="318"></A>     * 
<FONT ID="LN">319 </FONT><A NAME="319"></A>     * @return true iff we're looking at a [] pair; false otherwise.
<FONT ID="LN">320 </FONT><A NAME="320"></A>     */</FONT>
<FONT ID="LN">321 </FONT><A NAME="321"></A>
<FONT ID="LN">322 </FONT><A NAME="322"></A>    <FONT ID="Private">private</FONT> <FONT ID="Boolean">boolean</FONT> seeDims() {
<FONT ID="LN">323 </FONT><A NAME="323"></A>        scanner.recordPosition();
<FONT ID="LN">324 </FONT><A NAME="324"></A>        <FONT ID="Boolean">boolean</FONT> result = have(LBRACK) &amp;&amp; see(RBRACK);
<FONT ID="LN">325 </FONT><A NAME="325"></A>        scanner.returnToPosition();
<FONT ID="LN">326 </FONT><A NAME="326"></A>        <FONT ID="Return">return</FONT> result;
<FONT ID="LN">327 </FONT><A NAME="327"></A>    }
<FONT ID="LN">328 </FONT><A NAME="328"></A>
<FONT ID="LN">329 </FONT><A NAME="329"></A>    <FONT ID="SingleLineComment">// ////////////////////////////////////////////////
<FONT ID="LN">330 </FONT><A NAME="330"></A></FONT>    <FONT ID="SingleLineComment">// Parser Proper /////////////////////////////////
<FONT ID="LN">331 </FONT><A NAME="331"></A></FONT>    <FONT ID="SingleLineComment">// ////////////////////////////////////////////////
<FONT ID="LN">332 </FONT><A NAME="332"></A></FONT>
<FONT ID="LN">333 </FONT><A NAME="333"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">334 </FONT><A NAME="334"></A>     * Parse a compilation unit (a program file) and construct an AST for it.
<FONT ID="LN">335 </FONT><A NAME="335"></A>     * After constructing the Parser, this is its entry point.
<FONT ID="LN">336 </FONT><A NAME="336"></A>     * 
<FONT ID="LN">337 </FONT><A NAME="337"></A>     * &lt;pre&gt;
<FONT ID="LN">338 </FONT><A NAME="338"></A>     *   compilationUnit ::= [PACKAGE qualifiedIdentifier SEMI]
<FONT ID="LN">339 </FONT><A NAME="339"></A>     *                       {IMPORT  qualifiedIdentifier SEMI}
<FONT ID="LN">340 </FONT><A NAME="340"></A>     *                       {typeDeclaration}
<FONT ID="LN">341 </FONT><A NAME="341"></A>     *                       EOF
<FONT ID="LN">342 </FONT><A NAME="342"></A>     * &lt;/pre&gt;
<FONT ID="LN">343 </FONT><A NAME="343"></A>     * 
<FONT ID="LN">344 </FONT><A NAME="344"></A>     * @return an AST for a compilationUnit.
<FONT ID="LN">345 </FONT><A NAME="345"></A>     */</FONT>
<FONT ID="LN">346 </FONT><A NAME="346"></A>
<FONT ID="LN">347 </FONT><A NAME="347"></A>    <FONT ID="Public">public</FONT> <A HREF="../jminusminus/JCompilationUnit.java.html">JCompilationUnit</A> compilationUnit() {
<FONT ID="LN">348 </FONT><A NAME="348"></A>        <FONT ID="Int">int</FONT> line = scanner.token().line();
<FONT ID="LN">349 </FONT><A NAME="349"></A>        TypeName packageName = <FONT ID="Null">null</FONT>; <FONT ID="SingleLineComment">// Default
<FONT ID="LN">350 </FONT><A NAME="350"></A></FONT>        <FONT ID="If">if</FONT> (have(PACKAGE)) {
<FONT ID="LN">351 </FONT><A NAME="351"></A>            packageName = qualifiedIdentifier();
<FONT ID="LN">352 </FONT><A NAME="352"></A>            mustBe(SEMI);
<FONT ID="LN">353 </FONT><A NAME="353"></A>        }
<FONT ID="LN">354 </FONT><A NAME="354"></A>        ArrayList&lt;TypeName&gt; imports = <FONT ID="New">new</FONT> ArrayList&lt;TypeName&gt;();
<FONT ID="LN">355 </FONT><A NAME="355"></A>        <FONT ID="While">while</FONT> (have(IMPORT)) {
<FONT ID="LN">356 </FONT><A NAME="356"></A>            imports.add(qualifiedIdentifier());
<FONT ID="LN">357 </FONT><A NAME="357"></A>            mustBe(SEMI);
<FONT ID="LN">358 </FONT><A NAME="358"></A>        }
<FONT ID="LN">359 </FONT><A NAME="359"></A>        ArrayList&lt;<A HREF="../jminusminus/JAST.java.html">JAST</A>&gt; typeDeclarations = <FONT ID="New">new</FONT> ArrayList&lt;<A HREF="../jminusminus/JAST.java.html">JAST</A>&gt;();
<FONT ID="LN">360 </FONT><A NAME="360"></A>        <FONT ID="While">while</FONT> (!see(EOF)) {
<FONT ID="LN">361 </FONT><A NAME="361"></A>            <A HREF="../jminusminus/JAST.java.html">JAST</A> typeDeclaration = typeDeclaration();
<FONT ID="LN">362 </FONT><A NAME="362"></A>            <FONT ID="If">if</FONT> (typeDeclaration != <FONT ID="Null">null</FONT>) {
<FONT ID="LN">363 </FONT><A NAME="363"></A>                typeDeclarations.add(typeDeclaration);
<FONT ID="LN">364 </FONT><A NAME="364"></A>            }
<FONT ID="LN">365 </FONT><A NAME="365"></A>        }
<FONT ID="LN">366 </FONT><A NAME="366"></A>        mustBe(EOF);
<FONT ID="LN">367 </FONT><A NAME="367"></A>        <FONT ID="Return">return</FONT> <FONT ID="New">new</FONT> <A HREF="../jminusminus/JCompilationUnit.java.html">JCompilationUnit</A>(scanner.fileName(), line, packageName,
<FONT ID="LN">368 </FONT><A NAME="368"></A>                imports, typeDeclarations);
<FONT ID="LN">369 </FONT><A NAME="369"></A>    }
<FONT ID="LN">370 </FONT><A NAME="370"></A>
<FONT ID="LN">371 </FONT><A NAME="371"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">372 </FONT><A NAME="372"></A>     * Parse a qualified identifier.
<FONT ID="LN">373 </FONT><A NAME="373"></A>     * 
<FONT ID="LN">374 </FONT><A NAME="374"></A>     * &lt;pre&gt;
<FONT ID="LN">375 </FONT><A NAME="375"></A>     *   qualifiedIdentifier ::= IDENTIFIER {DOT IDENTIFIER}
<FONT ID="LN">376 </FONT><A NAME="376"></A>     * &lt;/pre&gt;
<FONT ID="LN">377 </FONT><A NAME="377"></A>     * 
<FONT ID="LN">378 </FONT><A NAME="378"></A>     * @return an instance of TypeName.
<FONT ID="LN">379 </FONT><A NAME="379"></A>     */</FONT>
<FONT ID="LN">380 </FONT><A NAME="380"></A>
<FONT ID="LN">381 </FONT><A NAME="381"></A>    <FONT ID="Private">private</FONT> TypeName qualifiedIdentifier() {
<FONT ID="LN">382 </FONT><A NAME="382"></A>        <FONT ID="Int">int</FONT> line = scanner.token().line();
<FONT ID="LN">383 </FONT><A NAME="383"></A>        mustBe(IDENTIFIER);
<FONT ID="LN">384 </FONT><A NAME="384"></A>        String qualifiedIdentifier = scanner.previousToken().image();
<FONT ID="LN">385 </FONT><A NAME="385"></A>        <FONT ID="While">while</FONT> (have(DOT)) {
<FONT ID="LN">386 </FONT><A NAME="386"></A>            mustBe(IDENTIFIER);
<FONT ID="LN">387 </FONT><A NAME="387"></A>            qualifiedIdentifier += <FONT ID="StringLiteral">"."</FONT> + scanner.previousToken().image();
<FONT ID="LN">388 </FONT><A NAME="388"></A>        }
<FONT ID="LN">389 </FONT><A NAME="389"></A>        <FONT ID="Return">return</FONT> <FONT ID="New">new</FONT> TypeName(line, qualifiedIdentifier);
<FONT ID="LN">390 </FONT><A NAME="390"></A>    }
<FONT ID="LN">391 </FONT><A NAME="391"></A>
<FONT ID="LN">392 </FONT><A NAME="392"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">393 </FONT><A NAME="393"></A>     * Parse a type declaration.
<FONT ID="LN">394 </FONT><A NAME="394"></A>     * 
<FONT ID="LN">395 </FONT><A NAME="395"></A>     * &lt;pre&gt;
<FONT ID="LN">396 </FONT><A NAME="396"></A>     *   typeDeclaration ::= modifiers classDeclaration
<FONT ID="LN">397 </FONT><A NAME="397"></A>     * &lt;/pre&gt;
<FONT ID="LN">398 </FONT><A NAME="398"></A>     * 
<FONT ID="LN">399 </FONT><A NAME="399"></A>     * @return an AST for a typeDeclaration.
<FONT ID="LN">400 </FONT><A NAME="400"></A>     */</FONT>
<FONT ID="LN">401 </FONT><A NAME="401"></A>
<FONT ID="LN">402 </FONT><A NAME="402"></A>    <FONT ID="Private">private</FONT> <A HREF="../jminusminus/JAST.java.html">JAST</A> typeDeclaration() {
<FONT ID="LN">403 </FONT><A NAME="403"></A>        ArrayList&lt;String&gt; mods = modifiers();
<FONT ID="LN">404 </FONT><A NAME="404"></A>        <FONT ID="Return">return</FONT> classDeclaration(mods);
<FONT ID="LN">405 </FONT><A NAME="405"></A>    }
<FONT ID="LN">406 </FONT><A NAME="406"></A>
<FONT ID="LN">407 </FONT><A NAME="407"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">408 </FONT><A NAME="408"></A>     * Parse modifiers.
<FONT ID="LN">409 </FONT><A NAME="409"></A>     * 
<FONT ID="LN">410 </FONT><A NAME="410"></A>     * &lt;pre&gt;
<FONT ID="LN">411 </FONT><A NAME="411"></A>     *   modifiers ::= {PUBLIC | PROTECTED | PRIVATE | STATIC | 
<FONT ID="LN">412 </FONT><A NAME="412"></A>     *                  ABSTRACT}
<FONT ID="LN">413 </FONT><A NAME="413"></A>     * &lt;/pre&gt;
<FONT ID="LN">414 </FONT><A NAME="414"></A>     * 
<FONT ID="LN">415 </FONT><A NAME="415"></A>     * Check for duplicates, and conflicts among access modifiers (public,
<FONT ID="LN">416 </FONT><A NAME="416"></A>     * protected, and private). Otherwise, no checks.
<FONT ID="LN">417 </FONT><A NAME="417"></A>     * 
<FONT ID="LN">418 </FONT><A NAME="418"></A>     * @return a list of modifiers.
<FONT ID="LN">419 </FONT><A NAME="419"></A>     */</FONT>
<FONT ID="LN">420 </FONT><A NAME="420"></A>
<FONT ID="LN">421 </FONT><A NAME="421"></A>    <FONT ID="Private">private</FONT> ArrayList&lt;String&gt; modifiers() {
<FONT ID="LN">422 </FONT><A NAME="422"></A>        ArrayList&lt;String&gt; mods = <FONT ID="New">new</FONT> ArrayList&lt;String&gt;();
<FONT ID="LN">423 </FONT><A NAME="423"></A>        <FONT ID="Boolean">boolean</FONT> scannedPUBLIC = <FONT ID="False">false</FONT>;
<FONT ID="LN">424 </FONT><A NAME="424"></A>        <FONT ID="Boolean">boolean</FONT> scannedPROTECTED = <FONT ID="False">false</FONT>;
<FONT ID="LN">425 </FONT><A NAME="425"></A>        <FONT ID="Boolean">boolean</FONT> scannedPRIVATE = <FONT ID="False">false</FONT>;
<FONT ID="LN">426 </FONT><A NAME="426"></A>        <FONT ID="Boolean">boolean</FONT> scannedSTATIC = <FONT ID="False">false</FONT>;
<FONT ID="LN">427 </FONT><A NAME="427"></A>        <FONT ID="Boolean">boolean</FONT> scannedABSTRACT = <FONT ID="False">false</FONT>;
<FONT ID="LN">428 </FONT><A NAME="428"></A>        <FONT ID="Boolean">boolean</FONT> more = <FONT ID="True">true</FONT>;
<FONT ID="LN">429 </FONT><A NAME="429"></A>        <FONT ID="While">while</FONT> (more)
<FONT ID="LN">430 </FONT><A NAME="430"></A>            <FONT ID="If">if</FONT> (have(PUBLIC)) {
<FONT ID="LN">431 </FONT><A NAME="431"></A>                mods.add(<FONT ID="StringLiteral">"public"</FONT>);
<FONT ID="LN">432 </FONT><A NAME="432"></A>                <FONT ID="If">if</FONT> (scannedPUBLIC) {
<FONT ID="LN">433 </FONT><A NAME="433"></A>                    reportParserError(<FONT ID="StringLiteral">"Repeated modifier: public"</FONT>);
<FONT ID="LN">434 </FONT><A NAME="434"></A>                }
<FONT ID="LN">435 </FONT><A NAME="435"></A>                <FONT ID="If">if</FONT> (scannedPROTECTED || scannedPRIVATE) {
<FONT ID="LN">436 </FONT><A NAME="436"></A>                    reportParserError(<FONT ID="StringLiteral">"Access conflict in modifiers"</FONT>);
<FONT ID="LN">437 </FONT><A NAME="437"></A>                }
<FONT ID="LN">438 </FONT><A NAME="438"></A>                scannedPUBLIC = <FONT ID="True">true</FONT>;
<FONT ID="LN">439 </FONT><A NAME="439"></A>            } <FONT ID="Else">else</FONT> <FONT ID="If">if</FONT> (have(PROTECTED)) {
<FONT ID="LN">440 </FONT><A NAME="440"></A>                mods.add(<FONT ID="StringLiteral">"protected"</FONT>);
<FONT ID="LN">441 </FONT><A NAME="441"></A>                <FONT ID="If">if</FONT> (scannedPROTECTED) {
<FONT ID="LN">442 </FONT><A NAME="442"></A>                    reportParserError(<FONT ID="StringLiteral">"Repeated modifier: protected"</FONT>);
<FONT ID="LN">443 </FONT><A NAME="443"></A>                }
<FONT ID="LN">444 </FONT><A NAME="444"></A>                <FONT ID="If">if</FONT> (scannedPUBLIC || scannedPRIVATE) {
<FONT ID="LN">445 </FONT><A NAME="445"></A>                    reportParserError(<FONT ID="StringLiteral">"Access conflict in modifiers"</FONT>);
<FONT ID="LN">446 </FONT><A NAME="446"></A>                }
<FONT ID="LN">447 </FONT><A NAME="447"></A>                scannedPROTECTED = <FONT ID="True">true</FONT>;
<FONT ID="LN">448 </FONT><A NAME="448"></A>            } <FONT ID="Else">else</FONT> <FONT ID="If">if</FONT> (have(PRIVATE)) {
<FONT ID="LN">449 </FONT><A NAME="449"></A>                mods.add(<FONT ID="StringLiteral">"private"</FONT>);
<FONT ID="LN">450 </FONT><A NAME="450"></A>                <FONT ID="If">if</FONT> (scannedPRIVATE) {
<FONT ID="LN">451 </FONT><A NAME="451"></A>                    reportParserError(<FONT ID="StringLiteral">"Repeated modifier: private"</FONT>);
<FONT ID="LN">452 </FONT><A NAME="452"></A>                }
<FONT ID="LN">453 </FONT><A NAME="453"></A>                <FONT ID="If">if</FONT> (scannedPUBLIC || scannedPROTECTED) {
<FONT ID="LN">454 </FONT><A NAME="454"></A>                    reportParserError(<FONT ID="StringLiteral">"Access conflict in modifiers"</FONT>);
<FONT ID="LN">455 </FONT><A NAME="455"></A>                }
<FONT ID="LN">456 </FONT><A NAME="456"></A>                scannedPRIVATE = <FONT ID="True">true</FONT>;
<FONT ID="LN">457 </FONT><A NAME="457"></A>            } <FONT ID="Else">else</FONT> <FONT ID="If">if</FONT> (have(STATIC)) {
<FONT ID="LN">458 </FONT><A NAME="458"></A>                mods.add(<FONT ID="StringLiteral">"static"</FONT>);
<FONT ID="LN">459 </FONT><A NAME="459"></A>                <FONT ID="If">if</FONT> (scannedSTATIC) {
<FONT ID="LN">460 </FONT><A NAME="460"></A>                    reportParserError(<FONT ID="StringLiteral">"Repeated modifier: static"</FONT>);
<FONT ID="LN">461 </FONT><A NAME="461"></A>                }
<FONT ID="LN">462 </FONT><A NAME="462"></A>                scannedSTATIC = <FONT ID="True">true</FONT>;
<FONT ID="LN">463 </FONT><A NAME="463"></A>            } <FONT ID="Else">else</FONT> <FONT ID="If">if</FONT> (have(ABSTRACT)) {
<FONT ID="LN">464 </FONT><A NAME="464"></A>                mods.add(<FONT ID="StringLiteral">"abstract"</FONT>);
<FONT ID="LN">465 </FONT><A NAME="465"></A>                <FONT ID="If">if</FONT> (scannedABSTRACT) {
<FONT ID="LN">466 </FONT><A NAME="466"></A>                    reportParserError(<FONT ID="StringLiteral">"Repeated modifier: abstract"</FONT>);
<FONT ID="LN">467 </FONT><A NAME="467"></A>                }
<FONT ID="LN">468 </FONT><A NAME="468"></A>                scannedABSTRACT = <FONT ID="True">true</FONT>;
<FONT ID="LN">469 </FONT><A NAME="469"></A>            } <FONT ID="Else">else</FONT> {
<FONT ID="LN">470 </FONT><A NAME="470"></A>                more = <FONT ID="False">false</FONT>;
<FONT ID="LN">471 </FONT><A NAME="471"></A>            }
<FONT ID="LN">472 </FONT><A NAME="472"></A>        <FONT ID="Return">return</FONT> mods;
<FONT ID="LN">473 </FONT><A NAME="473"></A>    }
<FONT ID="LN">474 </FONT><A NAME="474"></A>
<FONT ID="LN">475 </FONT><A NAME="475"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">476 </FONT><A NAME="476"></A>     * Parse a class declaration.
<FONT ID="LN">477 </FONT><A NAME="477"></A>     * 
<FONT ID="LN">478 </FONT><A NAME="478"></A>     * &lt;pre&gt;
<FONT ID="LN">479 </FONT><A NAME="479"></A>     *   classDeclaration ::= CLASS IDENTIFIER 
<FONT ID="LN">480 </FONT><A NAME="480"></A>     *                        [EXTENDS qualifiedIdentifier] 
<FONT ID="LN">481 </FONT><A NAME="481"></A>     *                        classBody
<FONT ID="LN">482 </FONT><A NAME="482"></A>     * &lt;/pre&gt;
<FONT ID="LN">483 </FONT><A NAME="483"></A>     * 
<FONT ID="LN">484 </FONT><A NAME="484"></A>     * A class which doesn't explicitly extend another (super) class implicitly
<FONT ID="LN">485 </FONT><A NAME="485"></A>     * extends the superclass java.lang.Object.
<FONT ID="LN">486 </FONT><A NAME="486"></A>     * 
<FONT ID="LN">487 </FONT><A NAME="487"></A>     * @param mods
<FONT ID="LN">488 </FONT><A NAME="488"></A>     *            the class modifiers.
<FONT ID="LN">489 </FONT><A NAME="489"></A>     * @return an AST for a classDeclaration.
<FONT ID="LN">490 </FONT><A NAME="490"></A>     */</FONT>
<FONT ID="LN">491 </FONT><A NAME="491"></A>
<FONT ID="LN">492 </FONT><A NAME="492"></A>    <FONT ID="Private">private</FONT> <A HREF="../jminusminus/JClassDeclaration.java.html">JClassDeclaration</A> classDeclaration(ArrayList&lt;String&gt; mods) {
<FONT ID="LN">493 </FONT><A NAME="493"></A>        <FONT ID="Int">int</FONT> line = scanner.token().line();
<FONT ID="LN">494 </FONT><A NAME="494"></A>        mustBe(CLASS);
<FONT ID="LN">495 </FONT><A NAME="495"></A>        mustBe(IDENTIFIER);
<FONT ID="LN">496 </FONT><A NAME="496"></A>        String name = scanner.previousToken().image();
<FONT ID="LN">497 </FONT><A NAME="497"></A>        <A HREF="../jminusminus/Type.java.html">Type</A> superClass;
<FONT ID="LN">498 </FONT><A NAME="498"></A>        <FONT ID="If">if</FONT> (have(EXTENDS)) {
<FONT ID="LN">499 </FONT><A NAME="499"></A>            superClass = qualifiedIdentifier();
<FONT ID="LN">500 </FONT><A NAME="500"></A>        } <FONT ID="Else">else</FONT> {
<FONT ID="LN">501 </FONT><A NAME="501"></A>            superClass = Type.OBJECT;
<FONT ID="LN">502 </FONT><A NAME="502"></A>        }
<FONT ID="LN">503 </FONT><A NAME="503"></A>        <FONT ID="Return">return</FONT> <FONT ID="New">new</FONT> <A HREF="../jminusminus/JClassDeclaration.java.html">JClassDeclaration</A>(line, mods, name, superClass, classBody());
<FONT ID="LN">504 </FONT><A NAME="504"></A>    }
<FONT ID="LN">505 </FONT><A NAME="505"></A>
<FONT ID="LN">506 </FONT><A NAME="506"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">507 </FONT><A NAME="507"></A>     * Parse a class body.
<FONT ID="LN">508 </FONT><A NAME="508"></A>     * 
<FONT ID="LN">509 </FONT><A NAME="509"></A>     * &lt;pre&gt;
<FONT ID="LN">510 </FONT><A NAME="510"></A>     *   classBody ::= LCURLY
<FONT ID="LN">511 </FONT><A NAME="511"></A>     *                   {modifiers memberDecl}
<FONT ID="LN">512 </FONT><A NAME="512"></A>     *                 RCURLY
<FONT ID="LN">513 </FONT><A NAME="513"></A>     * &lt;/pre&gt;
<FONT ID="LN">514 </FONT><A NAME="514"></A>     * 
<FONT ID="LN">515 </FONT><A NAME="515"></A>     * @return list of members in the class body.
<FONT ID="LN">516 </FONT><A NAME="516"></A>     */</FONT>
<FONT ID="LN">517 </FONT><A NAME="517"></A>
<FONT ID="LN">518 </FONT><A NAME="518"></A>    <FONT ID="Private">private</FONT> ArrayList&lt;<A HREF="../jminusminus/JMember.java.html">JMember</A>&gt; classBody() {
<FONT ID="LN">519 </FONT><A NAME="519"></A>        ArrayList&lt;<A HREF="../jminusminus/JMember.java.html">JMember</A>&gt; members = <FONT ID="New">new</FONT> ArrayList&lt;<A HREF="../jminusminus/JMember.java.html">JMember</A>&gt;();
<FONT ID="LN">520 </FONT><A NAME="520"></A>        mustBe(LCURLY);
<FONT ID="LN">521 </FONT><A NAME="521"></A>        <FONT ID="While">while</FONT> (!see(RCURLY) &amp;&amp; !see(EOF)) {
<FONT ID="LN">522 </FONT><A NAME="522"></A>            members.add(memberDecl(modifiers()));
<FONT ID="LN">523 </FONT><A NAME="523"></A>        }
<FONT ID="LN">524 </FONT><A NAME="524"></A>        mustBe(RCURLY);
<FONT ID="LN">525 </FONT><A NAME="525"></A>        <FONT ID="Return">return</FONT> members;
<FONT ID="LN">526 </FONT><A NAME="526"></A>    }
<FONT ID="LN">527 </FONT><A NAME="527"></A>
<FONT ID="LN">528 </FONT><A NAME="528"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">529 </FONT><A NAME="529"></A>     * Parse a member declaration.
<FONT ID="LN">530 </FONT><A NAME="530"></A>     * 
<FONT ID="LN">531 </FONT><A NAME="531"></A>     * &lt;pre&gt;
<FONT ID="LN">532 </FONT><A NAME="532"></A>     *   memberDecl ::= IDENTIFIER            // constructor
<FONT ID="LN">533 </FONT><A NAME="533"></A>     *                    formalParameters
<FONT ID="LN">534 </FONT><A NAME="534"></A>     *                    block
<FONT ID="LN">535 </FONT><A NAME="535"></A>     *                | (VOID | type) IDENTIFIER  // method
<FONT ID="LN">536 </FONT><A NAME="536"></A>     *                    formalParameters
<FONT ID="LN">537 </FONT><A NAME="537"></A>     *                    (block | SEMI)
<FONT ID="LN">538 </FONT><A NAME="538"></A>     *                | type variableDeclarators SEMI
<FONT ID="LN">539 </FONT><A NAME="539"></A>     * &lt;/pre&gt;
<FONT ID="LN">540 </FONT><A NAME="540"></A>     * 
<FONT ID="LN">541 </FONT><A NAME="541"></A>     * @param mods
<FONT ID="LN">542 </FONT><A NAME="542"></A>     *            the class member modifiers.
<FONT ID="LN">543 </FONT><A NAME="543"></A>     * @return an AST for a memberDecl.
<FONT ID="LN">544 </FONT><A NAME="544"></A>     */</FONT>
<FONT ID="LN">545 </FONT><A NAME="545"></A>
<FONT ID="LN">546 </FONT><A NAME="546"></A>    <FONT ID="Private">private</FONT> <A HREF="../jminusminus/JMember.java.html">JMember</A> memberDecl(ArrayList&lt;String&gt; mods) {
<FONT ID="LN">547 </FONT><A NAME="547"></A>        <FONT ID="Int">int</FONT> line = scanner.token().line();
<FONT ID="LN">548 </FONT><A NAME="548"></A>        <A HREF="../jminusminus/JMember.java.html">JMember</A> memberDecl = <FONT ID="Null">null</FONT>;
<FONT ID="LN">549 </FONT><A NAME="549"></A>        <FONT ID="If">if</FONT> (seeIdentLParen()) {
<FONT ID="LN">550 </FONT><A NAME="550"></A>            <FONT ID="SingleLineComment">// A constructor
<FONT ID="LN">551 </FONT><A NAME="551"></A></FONT>            mustBe(IDENTIFIER);
<FONT ID="LN">552 </FONT><A NAME="552"></A>            String name = scanner.previousToken().image();
<FONT ID="LN">553 </FONT><A NAME="553"></A>            ArrayList&lt;<A HREF="../jminusminus/JFormalParameter.java.html">JFormalParameter</A>&gt; params = formalParameters();
<FONT ID="LN">554 </FONT><A NAME="554"></A>            <A HREF="../jminusminus/JBlock.java.html">JBlock</A> body = block();
<FONT ID="LN">555 </FONT><A NAME="555"></A>            memberDecl = <FONT ID="New">new</FONT> <A HREF="../jminusminus/JConstructorDeclaration.java.html">JConstructorDeclaration</A>(line, mods, name, params,
<FONT ID="LN">556 </FONT><A NAME="556"></A>                    body);
<FONT ID="LN">557 </FONT><A NAME="557"></A>        } <FONT ID="Else">else</FONT> {
<FONT ID="LN">558 </FONT><A NAME="558"></A>            <A HREF="../jminusminus/Type.java.html">Type</A> type = <FONT ID="Null">null</FONT>;
<FONT ID="LN">559 </FONT><A NAME="559"></A>            <FONT ID="If">if</FONT> (have(VOID)) {
<FONT ID="LN">560 </FONT><A NAME="560"></A>                <FONT ID="SingleLineComment">// void method
<FONT ID="LN">561 </FONT><A NAME="561"></A></FONT>                type = Type.VOID;
<FONT ID="LN">562 </FONT><A NAME="562"></A>                mustBe(IDENTIFIER);
<FONT ID="LN">563 </FONT><A NAME="563"></A>                String name = scanner.previousToken().image();
<FONT ID="LN">564 </FONT><A NAME="564"></A>                ArrayList&lt;<A HREF="../jminusminus/JFormalParameter.java.html">JFormalParameter</A>&gt; params = formalParameters();
<FONT ID="LN">565 </FONT><A NAME="565"></A>                <A HREF="../jminusminus/JBlock.java.html">JBlock</A> body = have(SEMI) ? <FONT ID="Null">null</FONT> : block();
<FONT ID="LN">566 </FONT><A NAME="566"></A>                memberDecl = <FONT ID="New">new</FONT> <A HREF="../jminusminus/JMethodDeclaration.java.html">JMethodDeclaration</A>(line, mods, name, type,
<FONT ID="LN">567 </FONT><A NAME="567"></A>                        params, body);
<FONT ID="LN">568 </FONT><A NAME="568"></A>            } <FONT ID="Else">else</FONT> {
<FONT ID="LN">569 </FONT><A NAME="569"></A>                type = type();
<FONT ID="LN">570 </FONT><A NAME="570"></A>                <FONT ID="If">if</FONT> (seeIdentLParen()) {
<FONT ID="LN">571 </FONT><A NAME="571"></A>                    <FONT ID="SingleLineComment">// Non void method
<FONT ID="LN">572 </FONT><A NAME="572"></A></FONT>                    mustBe(IDENTIFIER);
<FONT ID="LN">573 </FONT><A NAME="573"></A>                    String name = scanner.previousToken().image();
<FONT ID="LN">574 </FONT><A NAME="574"></A>                    ArrayList&lt;<A HREF="../jminusminus/JFormalParameter.java.html">JFormalParameter</A>&gt; params = formalParameters();
<FONT ID="LN">575 </FONT><A NAME="575"></A>                    <A HREF="../jminusminus/JBlock.java.html">JBlock</A> body = have(SEMI) ? <FONT ID="Null">null</FONT> : block();
<FONT ID="LN">576 </FONT><A NAME="576"></A>                    memberDecl = <FONT ID="New">new</FONT> <A HREF="../jminusminus/JMethodDeclaration.java.html">JMethodDeclaration</A>(line, mods, name, type,
<FONT ID="LN">577 </FONT><A NAME="577"></A>                            params, body);
<FONT ID="LN">578 </FONT><A NAME="578"></A>                } <FONT ID="Else">else</FONT> {
<FONT ID="LN">579 </FONT><A NAME="579"></A>                    <FONT ID="SingleLineComment">// Field
<FONT ID="LN">580 </FONT><A NAME="580"></A></FONT>                    memberDecl = <FONT ID="New">new</FONT> <A HREF="../jminusminus/JFieldDeclaration.java.html">JFieldDeclaration</A>(line, mods,
<FONT ID="LN">581 </FONT><A NAME="581"></A>                            variableDeclarators(type));
<FONT ID="LN">582 </FONT><A NAME="582"></A>                    mustBe(SEMI);
<FONT ID="LN">583 </FONT><A NAME="583"></A>                }
<FONT ID="LN">584 </FONT><A NAME="584"></A>            }
<FONT ID="LN">585 </FONT><A NAME="585"></A>        }
<FONT ID="LN">586 </FONT><A NAME="586"></A>        <FONT ID="Return">return</FONT> memberDecl;
<FONT ID="LN">587 </FONT><A NAME="587"></A>    }
<FONT ID="LN">588 </FONT><A NAME="588"></A>
<FONT ID="LN">589 </FONT><A NAME="589"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">590 </FONT><A NAME="590"></A>     * Parse a block.
<FONT ID="LN">591 </FONT><A NAME="591"></A>     * 
<FONT ID="LN">592 </FONT><A NAME="592"></A>     * &lt;pre&gt;
<FONT ID="LN">593 </FONT><A NAME="593"></A>     *   block ::= LCURLY {blockStatement} RCURLY
<FONT ID="LN">594 </FONT><A NAME="594"></A>     * &lt;/pre&gt;
<FONT ID="LN">595 </FONT><A NAME="595"></A>     * 
<FONT ID="LN">596 </FONT><A NAME="596"></A>     * @return an AST for a block.
<FONT ID="LN">597 </FONT><A NAME="597"></A>     */</FONT>
<FONT ID="LN">598 </FONT><A NAME="598"></A>
<FONT ID="LN">599 </FONT><A NAME="599"></A>    <FONT ID="Private">private</FONT> <A HREF="../jminusminus/JBlock.java.html">JBlock</A> block() {
<FONT ID="LN">600 </FONT><A NAME="600"></A>        <FONT ID="Int">int</FONT> line = scanner.token().line();
<FONT ID="LN">601 </FONT><A NAME="601"></A>        ArrayList&lt;<A HREF="../jminusminus/JStatement.java.html">JStatement</A>&gt; statements = <FONT ID="New">new</FONT> ArrayList&lt;<A HREF="../jminusminus/JStatement.java.html">JStatement</A>&gt;();
<FONT ID="LN">602 </FONT><A NAME="602"></A>        mustBe(LCURLY);
<FONT ID="LN">603 </FONT><A NAME="603"></A>        <FONT ID="While">while</FONT> (!see(RCURLY) &amp;&amp; !see(EOF)) {
<FONT ID="LN">604 </FONT><A NAME="604"></A>            statements.add(blockStatement());
<FONT ID="LN">605 </FONT><A NAME="605"></A>        }
<FONT ID="LN">606 </FONT><A NAME="606"></A>        mustBe(RCURLY);
<FONT ID="LN">607 </FONT><A NAME="607"></A>        <FONT ID="Return">return</FONT> <FONT ID="New">new</FONT> <A HREF="../jminusminus/JBlock.java.html">JBlock</A>(line, statements);
<FONT ID="LN">608 </FONT><A NAME="608"></A>    }
<FONT ID="LN">609 </FONT><A NAME="609"></A>
<FONT ID="LN">610 </FONT><A NAME="610"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">611 </FONT><A NAME="611"></A>     * Parse a block statement.
<FONT ID="LN">612 </FONT><A NAME="612"></A>     * 
<FONT ID="LN">613 </FONT><A NAME="613"></A>     * &lt;pre&gt;
<FONT ID="LN">614 </FONT><A NAME="614"></A>     *   blockStatement ::= localVariableDeclarationStatement
<FONT ID="LN">615 </FONT><A NAME="615"></A>     *                    | statement
<FONT ID="LN">616 </FONT><A NAME="616"></A>     * &lt;/pre&gt;
<FONT ID="LN">617 </FONT><A NAME="617"></A>     * 
<FONT ID="LN">618 </FONT><A NAME="618"></A>     * @return an AST for a blockStatement.
<FONT ID="LN">619 </FONT><A NAME="619"></A>     */</FONT>
<FONT ID="LN">620 </FONT><A NAME="620"></A>
<FONT ID="LN">621 </FONT><A NAME="621"></A>    <FONT ID="Private">private</FONT> <A HREF="../jminusminus/JStatement.java.html">JStatement</A> blockStatement() {
<FONT ID="LN">622 </FONT><A NAME="622"></A>        <FONT ID="If">if</FONT> (seeLocalVariableDeclaration()) {
<FONT ID="LN">623 </FONT><A NAME="623"></A>            <FONT ID="Return">return</FONT> localVariableDeclarationStatement();
<FONT ID="LN">624 </FONT><A NAME="624"></A>        } <FONT ID="Else">else</FONT> {
<FONT ID="LN">625 </FONT><A NAME="625"></A>            <FONT ID="Return">return</FONT> statement();
<FONT ID="LN">626 </FONT><A NAME="626"></A>        }
<FONT ID="LN">627 </FONT><A NAME="627"></A>    }
<FONT ID="LN">628 </FONT><A NAME="628"></A>
<FONT ID="LN">629 </FONT><A NAME="629"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">630 </FONT><A NAME="630"></A>     * Parse a statement.
<FONT ID="LN">631 </FONT><A NAME="631"></A>     * 
<FONT ID="LN">632 </FONT><A NAME="632"></A>     * &lt;pre&gt;
<FONT ID="LN">633 </FONT><A NAME="633"></A>     *   statement ::= block
<FONT ID="LN">634 </FONT><A NAME="634"></A>     *               | IF parExpression statement [ELSE statement]
<FONT ID="LN">635 </FONT><A NAME="635"></A>     *               | WHILE parExpression statement 
<FONT ID="LN">636 </FONT><A NAME="636"></A>     *               | RETURN [expression] SEMI
<FONT ID="LN">637 </FONT><A NAME="637"></A>     *               | SEMI 
<FONT ID="LN">638 </FONT><A NAME="638"></A>     *               | statementExpression SEMI
<FONT ID="LN">639 </FONT><A NAME="639"></A>     * &lt;/pre&gt;
<FONT ID="LN">640 </FONT><A NAME="640"></A>     * 
<FONT ID="LN">641 </FONT><A NAME="641"></A>     * @return an AST for a statement.
<FONT ID="LN">642 </FONT><A NAME="642"></A>     */</FONT>
<FONT ID="LN">643 </FONT><A NAME="643"></A>
<FONT ID="LN">644 </FONT><A NAME="644"></A>    <FONT ID="Private">private</FONT> <A HREF="../jminusminus/JStatement.java.html">JStatement</A> statement() {
<FONT ID="LN">645 </FONT><A NAME="645"></A>        <FONT ID="Int">int</FONT> line = scanner.token().line();
<FONT ID="LN">646 </FONT><A NAME="646"></A>        <FONT ID="If">if</FONT> (see(LCURLY)) {
<FONT ID="LN">647 </FONT><A NAME="647"></A>            <FONT ID="Return">return</FONT> block();
<FONT ID="LN">648 </FONT><A NAME="648"></A>        } <FONT ID="Else">else</FONT> <FONT ID="If">if</FONT> (have(IF)) {
<FONT ID="LN">649 </FONT><A NAME="649"></A>            <A HREF="../jminusminus/JExpression.java.html">JExpression</A> test = parExpression();
<FONT ID="LN">650 </FONT><A NAME="650"></A>            <A HREF="../jminusminus/JStatement.java.html">JStatement</A> consequent = statement();
<FONT ID="LN">651 </FONT><A NAME="651"></A>            <A HREF="../jminusminus/JStatement.java.html">JStatement</A> alternate = have(ELSE) ? statement() : <FONT ID="Null">null</FONT>;
<FONT ID="LN">652 </FONT><A NAME="652"></A>            <FONT ID="Return">return</FONT> <FONT ID="New">new</FONT> <A HREF="../jminusminus/JIfStatement.java.html">JIfStatement</A>(line, test, consequent, alternate);
<FONT ID="LN">653 </FONT><A NAME="653"></A>        } <FONT ID="Else">else</FONT> <FONT ID="If">if</FONT> (have(WHILE)) {
<FONT ID="LN">654 </FONT><A NAME="654"></A>            <A HREF="../jminusminus/JExpression.java.html">JExpression</A> test = parExpression();
<FONT ID="LN">655 </FONT><A NAME="655"></A>            <A HREF="../jminusminus/JStatement.java.html">JStatement</A> statement = statement();
<FONT ID="LN">656 </FONT><A NAME="656"></A>            <FONT ID="Return">return</FONT> <FONT ID="New">new</FONT> <A HREF="../jminusminus/JWhileStatement.java.html">JWhileStatement</A>(line, test, statement);
<FONT ID="LN">657 </FONT><A NAME="657"></A>        } <FONT ID="Else">else</FONT> <FONT ID="If">if</FONT> (have(RETURN)) {
<FONT ID="LN">658 </FONT><A NAME="658"></A>            <FONT ID="If">if</FONT> (have(SEMI)) {
<FONT ID="LN">659 </FONT><A NAME="659"></A>                <FONT ID="Return">return</FONT> <FONT ID="New">new</FONT> <A HREF="../jminusminus/JReturnStatement.java.html">JReturnStatement</A>(line, <FONT ID="Null">null</FONT>);
<FONT ID="LN">660 </FONT><A NAME="660"></A>            } <FONT ID="Else">else</FONT> {
<FONT ID="LN">661 </FONT><A NAME="661"></A>                <A HREF="../jminusminus/JExpression.java.html">JExpression</A> expr = expression();
<FONT ID="LN">662 </FONT><A NAME="662"></A>                mustBe(SEMI);
<FONT ID="LN">663 </FONT><A NAME="663"></A>                <FONT ID="Return">return</FONT> <FONT ID="New">new</FONT> <A HREF="../jminusminus/JReturnStatement.java.html">JReturnStatement</A>(line, expr);
<FONT ID="LN">664 </FONT><A NAME="664"></A>            }
<FONT ID="LN">665 </FONT><A NAME="665"></A>        } <FONT ID="Else">else</FONT> <FONT ID="If">if</FONT> (have(SEMI)) {
<FONT ID="LN">666 </FONT><A NAME="666"></A>            <FONT ID="Return">return</FONT> <FONT ID="New">new</FONT> <A HREF="../jminusminus/JEmptyStatement.java.html">JEmptyStatement</A>(line);
<FONT ID="LN">667 </FONT><A NAME="667"></A>        } <FONT ID="Else">else</FONT> { <FONT ID="SingleLineComment">// Must be a statementExpression
<FONT ID="LN">668 </FONT><A NAME="668"></A></FONT>            <A HREF="../jminusminus/JStatement.java.html">JStatement</A> statement = statementExpression();
<FONT ID="LN">669 </FONT><A NAME="669"></A>            mustBe(SEMI);
<FONT ID="LN">670 </FONT><A NAME="670"></A>            <FONT ID="Return">return</FONT> statement;
<FONT ID="LN">671 </FONT><A NAME="671"></A>        }
<FONT ID="LN">672 </FONT><A NAME="672"></A>    }
<FONT ID="LN">673 </FONT><A NAME="673"></A>
<FONT ID="LN">674 </FONT><A NAME="674"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">675 </FONT><A NAME="675"></A>     * Parse formal parameters.
<FONT ID="LN">676 </FONT><A NAME="676"></A>     * 
<FONT ID="LN">677 </FONT><A NAME="677"></A>     * &lt;pre&gt;
<FONT ID="LN">678 </FONT><A NAME="678"></A>     *   formalParameters ::= LPAREN 
<FONT ID="LN">679 </FONT><A NAME="679"></A>     *                          [formalParameter 
<FONT ID="LN">680 </FONT><A NAME="680"></A>     *                            {COMMA  formalParameter}]
<FONT ID="LN">681 </FONT><A NAME="681"></A>     *                        RPAREN
<FONT ID="LN">682 </FONT><A NAME="682"></A>     * &lt;/pre&gt;
<FONT ID="LN">683 </FONT><A NAME="683"></A>     * 
<FONT ID="LN">684 </FONT><A NAME="684"></A>     * @return a list of formal parameters.
<FONT ID="LN">685 </FONT><A NAME="685"></A>     */</FONT>
<FONT ID="LN">686 </FONT><A NAME="686"></A>
<FONT ID="LN">687 </FONT><A NAME="687"></A>    <FONT ID="Private">private</FONT> ArrayList&lt;<A HREF="../jminusminus/JFormalParameter.java.html">JFormalParameter</A>&gt; formalParameters() {
<FONT ID="LN">688 </FONT><A NAME="688"></A>        ArrayList&lt;<A HREF="../jminusminus/JFormalParameter.java.html">JFormalParameter</A>&gt; parameters = <FONT ID="New">new</FONT> ArrayList&lt;<A HREF="../jminusminus/JFormalParameter.java.html">JFormalParameter</A>&gt;();
<FONT ID="LN">689 </FONT><A NAME="689"></A>        mustBe(LPAREN);
<FONT ID="LN">690 </FONT><A NAME="690"></A>        <FONT ID="If">if</FONT> (have(RPAREN))
<FONT ID="LN">691 </FONT><A NAME="691"></A>            <FONT ID="Return">return</FONT> parameters; <FONT ID="SingleLineComment">// ()
<FONT ID="LN">692 </FONT><A NAME="692"></A></FONT>        <FONT ID="Do">do</FONT> {
<FONT ID="LN">693 </FONT><A NAME="693"></A>            parameters.add(formalParameter());
<FONT ID="LN">694 </FONT><A NAME="694"></A>        } <FONT ID="While">while</FONT> (have(COMMA));
<FONT ID="LN">695 </FONT><A NAME="695"></A>        mustBe(RPAREN);
<FONT ID="LN">696 </FONT><A NAME="696"></A>        <FONT ID="Return">return</FONT> parameters;
<FONT ID="LN">697 </FONT><A NAME="697"></A>    }
<FONT ID="LN">698 </FONT><A NAME="698"></A>
<FONT ID="LN">699 </FONT><A NAME="699"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">700 </FONT><A NAME="700"></A>     * Parse a formal parameter.
<FONT ID="LN">701 </FONT><A NAME="701"></A>     * 
<FONT ID="LN">702 </FONT><A NAME="702"></A>     * &lt;pre&gt;
<FONT ID="LN">703 </FONT><A NAME="703"></A>     *   formalParameter ::= type IDENTIFIER
<FONT ID="LN">704 </FONT><A NAME="704"></A>     * &lt;/pre&gt;
<FONT ID="LN">705 </FONT><A NAME="705"></A>     * 
<FONT ID="LN">706 </FONT><A NAME="706"></A>     * @return an AST for a formalParameter.
<FONT ID="LN">707 </FONT><A NAME="707"></A>     */</FONT>
<FONT ID="LN">708 </FONT><A NAME="708"></A>
<FONT ID="LN">709 </FONT><A NAME="709"></A>    <FONT ID="Private">private</FONT> <A HREF="../jminusminus/JFormalParameter.java.html">JFormalParameter</A> formalParameter() {
<FONT ID="LN">710 </FONT><A NAME="710"></A>        <FONT ID="Int">int</FONT> line = scanner.token().line();
<FONT ID="LN">711 </FONT><A NAME="711"></A>        <A HREF="../jminusminus/Type.java.html">Type</A> type = type();
<FONT ID="LN">712 </FONT><A NAME="712"></A>        mustBe(IDENTIFIER);
<FONT ID="LN">713 </FONT><A NAME="713"></A>        String name = scanner.previousToken().image();
<FONT ID="LN">714 </FONT><A NAME="714"></A>        <FONT ID="Return">return</FONT> <FONT ID="New">new</FONT> <A HREF="../jminusminus/JFormalParameter.java.html">JFormalParameter</A>(line, name, type);
<FONT ID="LN">715 </FONT><A NAME="715"></A>    }
<FONT ID="LN">716 </FONT><A NAME="716"></A>
<FONT ID="LN">717 </FONT><A NAME="717"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">718 </FONT><A NAME="718"></A>     * Parse a parenthesized expression.
<FONT ID="LN">719 </FONT><A NAME="719"></A>     * 
<FONT ID="LN">720 </FONT><A NAME="720"></A>     * &lt;pre&gt;
<FONT ID="LN">721 </FONT><A NAME="721"></A>     *   parExpression ::= LPAREN expression RPAREN
<FONT ID="LN">722 </FONT><A NAME="722"></A>     * &lt;/pre&gt;
<FONT ID="LN">723 </FONT><A NAME="723"></A>     * 
<FONT ID="LN">724 </FONT><A NAME="724"></A>     * @return an AST for a parExpression.
<FONT ID="LN">725 </FONT><A NAME="725"></A>     */</FONT>
<FONT ID="LN">726 </FONT><A NAME="726"></A>
<FONT ID="LN">727 </FONT><A NAME="727"></A>    <FONT ID="Private">private</FONT> <A HREF="../jminusminus/JExpression.java.html">JExpression</A> parExpression() {
<FONT ID="LN">728 </FONT><A NAME="728"></A>        mustBe(LPAREN);
<FONT ID="LN">729 </FONT><A NAME="729"></A>        <A HREF="../jminusminus/JExpression.java.html">JExpression</A> expr = expression();
<FONT ID="LN">730 </FONT><A NAME="730"></A>        mustBe(RPAREN);
<FONT ID="LN">731 </FONT><A NAME="731"></A>        <FONT ID="Return">return</FONT> expr;
<FONT ID="LN">732 </FONT><A NAME="732"></A>    }
<FONT ID="LN">733 </FONT><A NAME="733"></A>
<FONT ID="LN">734 </FONT><A NAME="734"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">735 </FONT><A NAME="735"></A>     * Parse a local variable declaration statement.
<FONT ID="LN">736 </FONT><A NAME="736"></A>     * 
<FONT ID="LN">737 </FONT><A NAME="737"></A>     * &lt;pre&gt;
<FONT ID="LN">738 </FONT><A NAME="738"></A>     *   localVariableDeclarationStatement ::= type 
<FONT ID="LN">739 </FONT><A NAME="739"></A>     *                                           variableDeclarators 
<FONT ID="LN">740 </FONT><A NAME="740"></A>     *                                             SEMI
<FONT ID="LN">741 </FONT><A NAME="741"></A>     * &lt;/pre&gt;
<FONT ID="LN">742 </FONT><A NAME="742"></A>     * 
<FONT ID="LN">743 </FONT><A NAME="743"></A>     * @return an AST for a variableDeclaration.
<FONT ID="LN">744 </FONT><A NAME="744"></A>     */</FONT>
<FONT ID="LN">745 </FONT><A NAME="745"></A>
<FONT ID="LN">746 </FONT><A NAME="746"></A>    <FONT ID="Private">private</FONT> <A HREF="../jminusminus/JVariableDeclaration.java.html">JVariableDeclaration</A> localVariableDeclarationStatement() {
<FONT ID="LN">747 </FONT><A NAME="747"></A>        <FONT ID="Int">int</FONT> line = scanner.token().line();
<FONT ID="LN">748 </FONT><A NAME="748"></A>        ArrayList&lt;String&gt; mods = <FONT ID="New">new</FONT> ArrayList&lt;String&gt;();
<FONT ID="LN">749 </FONT><A NAME="749"></A>        ArrayList&lt;<A HREF="../jminusminus/JVariableDeclarator.java.html">JVariableDeclarator</A>&gt; vdecls = variableDeclarators(type());
<FONT ID="LN">750 </FONT><A NAME="750"></A>        mustBe(SEMI);
<FONT ID="LN">751 </FONT><A NAME="751"></A>        <FONT ID="Return">return</FONT> <FONT ID="New">new</FONT> <A HREF="../jminusminus/JVariableDeclaration.java.html">JVariableDeclaration</A>(line, mods, vdecls);
<FONT ID="LN">752 </FONT><A NAME="752"></A>    }
<FONT ID="LN">753 </FONT><A NAME="753"></A>
<FONT ID="LN">754 </FONT><A NAME="754"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">755 </FONT><A NAME="755"></A>     * Parse variable declarators.
<FONT ID="LN">756 </FONT><A NAME="756"></A>     * 
<FONT ID="LN">757 </FONT><A NAME="757"></A>     * &lt;pre&gt;
<FONT ID="LN">758 </FONT><A NAME="758"></A>     *   variableDeclarators ::= variableDeclarator 
<FONT ID="LN">759 </FONT><A NAME="759"></A>     *                             {COMMA variableDeclarator}
<FONT ID="LN">760 </FONT><A NAME="760"></A>     * &lt;/pre&gt;
<FONT ID="LN">761 </FONT><A NAME="761"></A>     * 
<FONT ID="LN">762 </FONT><A NAME="762"></A>     * @param type
<FONT ID="LN">763 </FONT><A NAME="763"></A>     *            type of the variables.
<FONT ID="LN">764 </FONT><A NAME="764"></A>     * @return a list of variable declarators.
<FONT ID="LN">765 </FONT><A NAME="765"></A>     */</FONT>
<FONT ID="LN">766 </FONT><A NAME="766"></A>
<FONT ID="LN">767 </FONT><A NAME="767"></A>    <FONT ID="Private">private</FONT> ArrayList&lt;<A HREF="../jminusminus/JVariableDeclarator.java.html">JVariableDeclarator</A>&gt; variableDeclarators(<A HREF="../jminusminus/Type.java.html">Type</A> type) {
<FONT ID="LN">768 </FONT><A NAME="768"></A>        ArrayList&lt;<A HREF="../jminusminus/JVariableDeclarator.java.html">JVariableDeclarator</A>&gt; variableDeclarators = <FONT ID="New">new</FONT> ArrayList&lt;<A HREF="../jminusminus/JVariableDeclarator.java.html">JVariableDeclarator</A>&gt;();
<FONT ID="LN">769 </FONT><A NAME="769"></A>        <FONT ID="Do">do</FONT> {
<FONT ID="LN">770 </FONT><A NAME="770"></A>            variableDeclarators.add(variableDeclarator(type));
<FONT ID="LN">771 </FONT><A NAME="771"></A>        } <FONT ID="While">while</FONT> (have(COMMA));
<FONT ID="LN">772 </FONT><A NAME="772"></A>        <FONT ID="Return">return</FONT> variableDeclarators;
<FONT ID="LN">773 </FONT><A NAME="773"></A>    }
<FONT ID="LN">774 </FONT><A NAME="774"></A>
<FONT ID="LN">775 </FONT><A NAME="775"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">776 </FONT><A NAME="776"></A>     * Parse a variable declarator.
<FONT ID="LN">777 </FONT><A NAME="777"></A>     * 
<FONT ID="LN">778 </FONT><A NAME="778"></A>     * &lt;pre&gt;
<FONT ID="LN">779 </FONT><A NAME="779"></A>     *   variableDeclarator ::= IDENTIFIER
<FONT ID="LN">780 </FONT><A NAME="780"></A>     *                          [ASSIGN variableInitializer]
<FONT ID="LN">781 </FONT><A NAME="781"></A>     * &lt;/pre&gt;
<FONT ID="LN">782 </FONT><A NAME="782"></A>     * 
<FONT ID="LN">783 </FONT><A NAME="783"></A>     * @param type
<FONT ID="LN">784 </FONT><A NAME="784"></A>     *            type of the variable.
<FONT ID="LN">785 </FONT><A NAME="785"></A>     * @return an AST for a variableDeclarator.
<FONT ID="LN">786 </FONT><A NAME="786"></A>     */</FONT>
<FONT ID="LN">787 </FONT><A NAME="787"></A>
<FONT ID="LN">788 </FONT><A NAME="788"></A>    <FONT ID="Private">private</FONT> <A HREF="../jminusminus/JVariableDeclarator.java.html">JVariableDeclarator</A> variableDeclarator(<A HREF="../jminusminus/Type.java.html">Type</A> type) {
<FONT ID="LN">789 </FONT><A NAME="789"></A>        <FONT ID="Int">int</FONT> line = scanner.token().line();
<FONT ID="LN">790 </FONT><A NAME="790"></A>        mustBe(IDENTIFIER);
<FONT ID="LN">791 </FONT><A NAME="791"></A>        String name = scanner.previousToken().image();
<FONT ID="LN">792 </FONT><A NAME="792"></A>        <A HREF="../jminusminus/JExpression.java.html">JExpression</A> initial = have(ASSIGN) ? variableInitializer(type) : <FONT ID="Null">null</FONT>;
<FONT ID="LN">793 </FONT><A NAME="793"></A>        <FONT ID="Return">return</FONT> <FONT ID="New">new</FONT> <A HREF="../jminusminus/JVariableDeclarator.java.html">JVariableDeclarator</A>(line, name, type, initial);
<FONT ID="LN">794 </FONT><A NAME="794"></A>    }
<FONT ID="LN">795 </FONT><A NAME="795"></A>
<FONT ID="LN">796 </FONT><A NAME="796"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">797 </FONT><A NAME="797"></A>     * Parse a variable initializer.
<FONT ID="LN">798 </FONT><A NAME="798"></A>     * 
<FONT ID="LN">799 </FONT><A NAME="799"></A>     * &lt;pre&gt;
<FONT ID="LN">800 </FONT><A NAME="800"></A>     *   variableInitializer ::= arrayInitializer
<FONT ID="LN">801 </FONT><A NAME="801"></A>     *                         | expression
<FONT ID="LN">802 </FONT><A NAME="802"></A>     * &lt;/pre&gt;
<FONT ID="LN">803 </FONT><A NAME="803"></A>     * 
<FONT ID="LN">804 </FONT><A NAME="804"></A>     * @param type
<FONT ID="LN">805 </FONT><A NAME="805"></A>     *            type of the variable.
<FONT ID="LN">806 </FONT><A NAME="806"></A>     * @return an AST for a variableInitializer.
<FONT ID="LN">807 </FONT><A NAME="807"></A>     */</FONT>
<FONT ID="LN">808 </FONT><A NAME="808"></A>
<FONT ID="LN">809 </FONT><A NAME="809"></A>    <FONT ID="Private">private</FONT> <A HREF="../jminusminus/JExpression.java.html">JExpression</A> variableInitializer(<A HREF="../jminusminus/Type.java.html">Type</A> type) {
<FONT ID="LN">810 </FONT><A NAME="810"></A>        <FONT ID="If">if</FONT> (see(LCURLY)) {
<FONT ID="LN">811 </FONT><A NAME="811"></A>            <FONT ID="Return">return</FONT> arrayInitializer(type);
<FONT ID="LN">812 </FONT><A NAME="812"></A>        }
<FONT ID="LN">813 </FONT><A NAME="813"></A>        <FONT ID="Return">return</FONT> expression();
<FONT ID="LN">814 </FONT><A NAME="814"></A>    }
<FONT ID="LN">815 </FONT><A NAME="815"></A>
<FONT ID="LN">816 </FONT><A NAME="816"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">817 </FONT><A NAME="817"></A>     * Parse an array initializer.
<FONT ID="LN">818 </FONT><A NAME="818"></A>     * 
<FONT ID="LN">819 </FONT><A NAME="819"></A>     * &lt;pre&gt;
<FONT ID="LN">820 </FONT><A NAME="820"></A>     *   arrayInitializer ::= LCURLY 
<FONT ID="LN">821 </FONT><A NAME="821"></A>     *                          [variableInitializer 
<FONT ID="LN">822 </FONT><A NAME="822"></A>     *                            {COMMA variableInitializer} [COMMA]]
<FONT ID="LN">823 </FONT><A NAME="823"></A>     *                        RCURLY
<FONT ID="LN">824 </FONT><A NAME="824"></A>     * &lt;/pre&gt;
<FONT ID="LN">825 </FONT><A NAME="825"></A>     * 
<FONT ID="LN">826 </FONT><A NAME="826"></A>     * @param type
<FONT ID="LN">827 </FONT><A NAME="827"></A>     *            type of the array.
<FONT ID="LN">828 </FONT><A NAME="828"></A>     * @return an AST for an arrayInitializer.
<FONT ID="LN">829 </FONT><A NAME="829"></A>     */</FONT>
<FONT ID="LN">830 </FONT><A NAME="830"></A>
<FONT ID="LN">831 </FONT><A NAME="831"></A>    <FONT ID="Private">private</FONT> <A HREF="../jminusminus/JArrayInitializer.java.html">JArrayInitializer</A> arrayInitializer(<A HREF="../jminusminus/Type.java.html">Type</A> type) {
<FONT ID="LN">832 </FONT><A NAME="832"></A>        <FONT ID="Int">int</FONT> line = scanner.token().line();
<FONT ID="LN">833 </FONT><A NAME="833"></A>        ArrayList&lt;<A HREF="../jminusminus/JExpression.java.html">JExpression</A>&gt; initials = <FONT ID="New">new</FONT> ArrayList&lt;<A HREF="../jminusminus/JExpression.java.html">JExpression</A>&gt;();
<FONT ID="LN">834 </FONT><A NAME="834"></A>        mustBe(LCURLY);
<FONT ID="LN">835 </FONT><A NAME="835"></A>        <FONT ID="If">if</FONT> (have(RCURLY)) {
<FONT ID="LN">836 </FONT><A NAME="836"></A>            <FONT ID="Return">return</FONT> <FONT ID="New">new</FONT> <A HREF="../jminusminus/JArrayInitializer.java.html">JArrayInitializer</A>(line, type, initials);
<FONT ID="LN">837 </FONT><A NAME="837"></A>        }
<FONT ID="LN">838 </FONT><A NAME="838"></A>        initials.add(variableInitializer(type.componentType()));
<FONT ID="LN">839 </FONT><A NAME="839"></A>        <FONT ID="While">while</FONT> (have(COMMA)) {
<FONT ID="LN">840 </FONT><A NAME="840"></A>            initials.add(see(RCURLY) ? <FONT ID="Null">null</FONT> : variableInitializer(type
<FONT ID="LN">841 </FONT><A NAME="841"></A>                    .componentType()));
<FONT ID="LN">842 </FONT><A NAME="842"></A>        }
<FONT ID="LN">843 </FONT><A NAME="843"></A>        mustBe(RCURLY);
<FONT ID="LN">844 </FONT><A NAME="844"></A>        <FONT ID="Return">return</FONT> <FONT ID="New">new</FONT> <A HREF="../jminusminus/JArrayInitializer.java.html">JArrayInitializer</A>(line, type, initials);
<FONT ID="LN">845 </FONT><A NAME="845"></A>    }
<FONT ID="LN">846 </FONT><A NAME="846"></A>
<FONT ID="LN">847 </FONT><A NAME="847"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">848 </FONT><A NAME="848"></A>     * Parse arguments.
<FONT ID="LN">849 </FONT><A NAME="849"></A>     * 
<FONT ID="LN">850 </FONT><A NAME="850"></A>     * &lt;pre&gt;
<FONT ID="LN">851 </FONT><A NAME="851"></A>     *   arguments ::= LPAREN [expression {COMMA expression}] RPAREN
<FONT ID="LN">852 </FONT><A NAME="852"></A>     * &lt;/pre&gt;
<FONT ID="LN">853 </FONT><A NAME="853"></A>     * 
<FONT ID="LN">854 </FONT><A NAME="854"></A>     * @return a list of expressions.
<FONT ID="LN">855 </FONT><A NAME="855"></A>     */</FONT>
<FONT ID="LN">856 </FONT><A NAME="856"></A>
<FONT ID="LN">857 </FONT><A NAME="857"></A>    <FONT ID="Private">private</FONT> ArrayList&lt;<A HREF="../jminusminus/JExpression.java.html">JExpression</A>&gt; arguments() {
<FONT ID="LN">858 </FONT><A NAME="858"></A>        ArrayList&lt;<A HREF="../jminusminus/JExpression.java.html">JExpression</A>&gt; args = <FONT ID="New">new</FONT> ArrayList&lt;<A HREF="../jminusminus/JExpression.java.html">JExpression</A>&gt;();
<FONT ID="LN">859 </FONT><A NAME="859"></A>        mustBe(LPAREN);
<FONT ID="LN">860 </FONT><A NAME="860"></A>        <FONT ID="If">if</FONT> (have(RPAREN)) {
<FONT ID="LN">861 </FONT><A NAME="861"></A>            <FONT ID="Return">return</FONT> args;
<FONT ID="LN">862 </FONT><A NAME="862"></A>        }
<FONT ID="LN">863 </FONT><A NAME="863"></A>        <FONT ID="Do">do</FONT> {
<FONT ID="LN">864 </FONT><A NAME="864"></A>            args.add(expression());
<FONT ID="LN">865 </FONT><A NAME="865"></A>        } <FONT ID="While">while</FONT> (have(COMMA));
<FONT ID="LN">866 </FONT><A NAME="866"></A>        mustBe(RPAREN);
<FONT ID="LN">867 </FONT><A NAME="867"></A>        <FONT ID="Return">return</FONT> args;
<FONT ID="LN">868 </FONT><A NAME="868"></A>    }
<FONT ID="LN">869 </FONT><A NAME="869"></A>
<FONT ID="LN">870 </FONT><A NAME="870"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">871 </FONT><A NAME="871"></A>     * Parse a type.
<FONT ID="LN">872 </FONT><A NAME="872"></A>     * 
<FONT ID="LN">873 </FONT><A NAME="873"></A>     * &lt;pre&gt;
<FONT ID="LN">874 </FONT><A NAME="874"></A>     *   type ::= referenceType 
<FONT ID="LN">875 </FONT><A NAME="875"></A>     *          | basicType
<FONT ID="LN">876 </FONT><A NAME="876"></A>     * &lt;/pre&gt;
<FONT ID="LN">877 </FONT><A NAME="877"></A>     * 
<FONT ID="LN">878 </FONT><A NAME="878"></A>     * @return an instance of Type.
<FONT ID="LN">879 </FONT><A NAME="879"></A>     */</FONT>
<FONT ID="LN">880 </FONT><A NAME="880"></A>
<FONT ID="LN">881 </FONT><A NAME="881"></A>    <FONT ID="Private">private</FONT> <A HREF="../jminusminus/Type.java.html">Type</A> type() {
<FONT ID="LN">882 </FONT><A NAME="882"></A>        <FONT ID="If">if</FONT> (seeReferenceType()) {
<FONT ID="LN">883 </FONT><A NAME="883"></A>            <FONT ID="Return">return</FONT> referenceType();
<FONT ID="LN">884 </FONT><A NAME="884"></A>        }
<FONT ID="LN">885 </FONT><A NAME="885"></A>        <FONT ID="Return">return</FONT> basicType();
<FONT ID="LN">886 </FONT><A NAME="886"></A>    }
<FONT ID="LN">887 </FONT><A NAME="887"></A>
<FONT ID="LN">888 </FONT><A NAME="888"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">889 </FONT><A NAME="889"></A>     * Parse a basic type.
<FONT ID="LN">890 </FONT><A NAME="890"></A>     * 
<FONT ID="LN">891 </FONT><A NAME="891"></A>     * &lt;pre&gt;
<FONT ID="LN">892 </FONT><A NAME="892"></A>     *   basicType ::= BOOLEAN | CHAR | INT
<FONT ID="LN">893 </FONT><A NAME="893"></A>     * &lt;/pre&gt;
<FONT ID="LN">894 </FONT><A NAME="894"></A>     * 
<FONT ID="LN">895 </FONT><A NAME="895"></A>     * @return an instance of Type.
<FONT ID="LN">896 </FONT><A NAME="896"></A>     */</FONT>
<FONT ID="LN">897 </FONT><A NAME="897"></A>
<FONT ID="LN">898 </FONT><A NAME="898"></A>    <FONT ID="Private">private</FONT> <A HREF="../jminusminus/Type.java.html">Type</A> basicType() {
<FONT ID="LN">899 </FONT><A NAME="899"></A>        <FONT ID="If">if</FONT> (have(BOOLEAN)) {
<FONT ID="LN">900 </FONT><A NAME="900"></A>            <FONT ID="Return">return</FONT> Type.BOOLEAN;
<FONT ID="LN">901 </FONT><A NAME="901"></A>        } <FONT ID="Else">else</FONT> <FONT ID="If">if</FONT> (have(CHAR)) {
<FONT ID="LN">902 </FONT><A NAME="902"></A>            <FONT ID="Return">return</FONT> Type.CHAR;
<FONT ID="LN">903 </FONT><A NAME="903"></A>        } <FONT ID="Else">else</FONT> <FONT ID="If">if</FONT> (have(INT)) {
<FONT ID="LN">904 </FONT><A NAME="904"></A>            <FONT ID="Return">return</FONT> Type.INT;
<FONT ID="LN">905 </FONT><A NAME="905"></A>        } <FONT ID="Else">else</FONT> {
<FONT ID="LN">906 </FONT><A NAME="906"></A>            reportParserError(<FONT ID="StringLiteral">"Type sought where %s found"</FONT>, scanner.token()
<FONT ID="LN">907 </FONT><A NAME="907"></A>                    .image());
<FONT ID="LN">908 </FONT><A NAME="908"></A>            <FONT ID="Return">return</FONT> Type.ANY;
<FONT ID="LN">909 </FONT><A NAME="909"></A>        }
<FONT ID="LN">910 </FONT><A NAME="910"></A>    }
<FONT ID="LN">911 </FONT><A NAME="911"></A>
<FONT ID="LN">912 </FONT><A NAME="912"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">913 </FONT><A NAME="913"></A>     * Parse a reference type.
<FONT ID="LN">914 </FONT><A NAME="914"></A>     * 
<FONT ID="LN">915 </FONT><A NAME="915"></A>     * &lt;pre&gt;
<FONT ID="LN">916 </FONT><A NAME="916"></A>     *   referenceType ::= basicType LBRACK RBRACK {LBRACK RBRACK}
<FONT ID="LN">917 </FONT><A NAME="917"></A>     *                   | qualifiedIdentifier {LBRACK RBRACK}
<FONT ID="LN">918 </FONT><A NAME="918"></A>     * &lt;/pre&gt;
<FONT ID="LN">919 </FONT><A NAME="919"></A>     * 
<FONT ID="LN">920 </FONT><A NAME="920"></A>     * @return an instance of Type.
<FONT ID="LN">921 </FONT><A NAME="921"></A>     */</FONT>
<FONT ID="LN">922 </FONT><A NAME="922"></A>
<FONT ID="LN">923 </FONT><A NAME="923"></A>    <FONT ID="Private">private</FONT> <A HREF="../jminusminus/Type.java.html">Type</A> referenceType() {
<FONT ID="LN">924 </FONT><A NAME="924"></A>        <A HREF="../jminusminus/Type.java.html">Type</A> type = <FONT ID="Null">null</FONT>;
<FONT ID="LN">925 </FONT><A NAME="925"></A>        <FONT ID="If">if</FONT> (!see(IDENTIFIER)) {
<FONT ID="LN">926 </FONT><A NAME="926"></A>            type = basicType();
<FONT ID="LN">927 </FONT><A NAME="927"></A>            mustBe(LBRACK);
<FONT ID="LN">928 </FONT><A NAME="928"></A>            mustBe(RBRACK);
<FONT ID="LN">929 </FONT><A NAME="929"></A>            type = <FONT ID="New">new</FONT> ArrayTypeName(type);
<FONT ID="LN">930 </FONT><A NAME="930"></A>        } <FONT ID="Else">else</FONT> {
<FONT ID="LN">931 </FONT><A NAME="931"></A>            type = qualifiedIdentifier();
<FONT ID="LN">932 </FONT><A NAME="932"></A>        }
<FONT ID="LN">933 </FONT><A NAME="933"></A>        <FONT ID="While">while</FONT> (seeDims()) {
<FONT ID="LN">934 </FONT><A NAME="934"></A>            mustBe(LBRACK);
<FONT ID="LN">935 </FONT><A NAME="935"></A>            mustBe(RBRACK);
<FONT ID="LN">936 </FONT><A NAME="936"></A>            type = <FONT ID="New">new</FONT> ArrayTypeName(type);
<FONT ID="LN">937 </FONT><A NAME="937"></A>        }
<FONT ID="LN">938 </FONT><A NAME="938"></A>        <FONT ID="Return">return</FONT> type;
<FONT ID="LN">939 </FONT><A NAME="939"></A>    }
<FONT ID="LN">940 </FONT><A NAME="940"></A>
<FONT ID="LN">941 </FONT><A NAME="941"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">942 </FONT><A NAME="942"></A>     * Parse a statement expression.
<FONT ID="LN">943 </FONT><A NAME="943"></A>     * 
<FONT ID="LN">944 </FONT><A NAME="944"></A>     * &lt;pre&gt;
<FONT ID="LN">945 </FONT><A NAME="945"></A>     *   statementExpression ::= expression // but must have 
<FONT ID="LN">946 </FONT><A NAME="946"></A>     *                                      // side-effect, eg i++
<FONT ID="LN">947 </FONT><A NAME="947"></A>     * &lt;/pre&gt;
<FONT ID="LN">948 </FONT><A NAME="948"></A>     * 
<FONT ID="LN">949 </FONT><A NAME="949"></A>     * @return an AST for a statementExpression.
<FONT ID="LN">950 </FONT><A NAME="950"></A>     */</FONT>
<FONT ID="LN">951 </FONT><A NAME="951"></A>
<FONT ID="LN">952 </FONT><A NAME="952"></A>    <FONT ID="Private">private</FONT> <A HREF="../jminusminus/JStatement.java.html">JStatement</A> statementExpression() {
<FONT ID="LN">953 </FONT><A NAME="953"></A>        <FONT ID="Int">int</FONT> line = scanner.token().line();
<FONT ID="LN">954 </FONT><A NAME="954"></A>        <A HREF="../jminusminus/JExpression.java.html">JExpression</A> expr = expression();
<FONT ID="LN">955 </FONT><A NAME="955"></A>        <FONT ID="If">if</FONT> (expr <FONT ID="InstanceOf">instanceof</FONT> <A HREF="../jminusminus/JAssignment.java.html">JAssignment</A> || expr <FONT ID="InstanceOf">instanceof</FONT> JPreIncrementOp
<FONT ID="LN">956 </FONT><A NAME="956"></A>                || expr <FONT ID="InstanceOf">instanceof</FONT> JPostDecrementOp
<FONT ID="LN">957 </FONT><A NAME="957"></A>                || expr <FONT ID="InstanceOf">instanceof</FONT> <A HREF="../jminusminus/JMessageExpression.java.html">JMessageExpression</A>
<FONT ID="LN">958 </FONT><A NAME="958"></A>                || expr <FONT ID="InstanceOf">instanceof</FONT> <A HREF="../jminusminus/JSuperConstruction.java.html">JSuperConstruction</A>
<FONT ID="LN">959 </FONT><A NAME="959"></A>                || expr <FONT ID="InstanceOf">instanceof</FONT> <A HREF="../jminusminus/JThisConstruction.java.html">JThisConstruction</A> || expr <FONT ID="InstanceOf">instanceof</FONT> <A HREF="../jminusminus/JNewOp.java.html">JNewOp</A>
<FONT ID="LN">960 </FONT><A NAME="960"></A>                || expr <FONT ID="InstanceOf">instanceof</FONT> <A HREF="../jminusminus/JNewArrayOp.java.html">JNewArrayOp</A>) {
<FONT ID="LN">961 </FONT><A NAME="961"></A>            <FONT ID="SingleLineComment">// So as not to save on stack
<FONT ID="LN">962 </FONT><A NAME="962"></A></FONT>            expr.isStatementExpression = <FONT ID="True">true</FONT>;
<FONT ID="LN">963 </FONT><A NAME="963"></A>        } <FONT ID="Else">else</FONT> {
<FONT ID="LN">964 </FONT><A NAME="964"></A>            reportParserError(<FONT ID="StringLiteral">"Invalid statement expression; "</FONT>
<FONT ID="LN">965 </FONT><A NAME="965"></A>                    + <FONT ID="StringLiteral">"it does not have a side-effect"</FONT>);
<FONT ID="LN">966 </FONT><A NAME="966"></A>        }
<FONT ID="LN">967 </FONT><A NAME="967"></A>        <FONT ID="Return">return</FONT> <FONT ID="New">new</FONT> <A HREF="../jminusminus/JStatementExpression.java.html">JStatementExpression</A>(line, expr);
<FONT ID="LN">968 </FONT><A NAME="968"></A>    }
<FONT ID="LN">969 </FONT><A NAME="969"></A>
<FONT ID="LN">970 </FONT><A NAME="970"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">971 </FONT><A NAME="971"></A>     * An expression.
<FONT ID="LN">972 </FONT><A NAME="972"></A>     * 
<FONT ID="LN">973 </FONT><A NAME="973"></A>     * &lt;pre&gt;
<FONT ID="LN">974 </FONT><A NAME="974"></A>     *   expression ::= assignmentExpression
<FONT ID="LN">975 </FONT><A NAME="975"></A>     * &lt;/pre&gt;
<FONT ID="LN">976 </FONT><A NAME="976"></A>     * 
<FONT ID="LN">977 </FONT><A NAME="977"></A>     * @return an AST for an expression.
<FONT ID="LN">978 </FONT><A NAME="978"></A>     */</FONT>
<FONT ID="LN">979 </FONT><A NAME="979"></A>
<FONT ID="LN">980 </FONT><A NAME="980"></A>    <FONT ID="Private">private</FONT> <A HREF="../jminusminus/JExpression.java.html">JExpression</A> expression() {
<FONT ID="LN">981 </FONT><A NAME="981"></A>        <FONT ID="Return">return</FONT> assignmentExpression();
<FONT ID="LN">982 </FONT><A NAME="982"></A>    }
<FONT ID="LN">983 </FONT><A NAME="983"></A>
<FONT ID="LN">984 </FONT><A NAME="984"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">985 </FONT><A NAME="985"></A>     * Parse an assignment expression.
<FONT ID="LN">986 </FONT><A NAME="986"></A>     * 
<FONT ID="LN">987 </FONT><A NAME="987"></A>     * &lt;pre&gt;
<FONT ID="LN">988 </FONT><A NAME="988"></A>     *   assignmentExpression ::= 
<FONT ID="LN">989 </FONT><A NAME="989"></A>     *       conditionalAndExpression // level 13
<FONT ID="LN">990 </FONT><A NAME="990"></A>     *           [( ASSIGN  // conditionalExpression
<FONT ID="LN">991 </FONT><A NAME="991"></A>     *            | PLUS_ASSIGN // must be valid lhs
<FONT ID="LN">992 </FONT><A NAME="992"></A>     *            )
<FONT ID="LN">993 </FONT><A NAME="993"></A>     *            assignmentExpression]
<FONT ID="LN">994 </FONT><A NAME="994"></A>     * &lt;/pre&gt;
<FONT ID="LN">995 </FONT><A NAME="995"></A>     * 
<FONT ID="LN">996 </FONT><A NAME="996"></A>     * @return an AST for an assignmentExpression.
<FONT ID="LN">997 </FONT><A NAME="997"></A>     */</FONT>
<FONT ID="LN">998 </FONT><A NAME="998"></A>
<FONT ID="LN">999 </FONT><A NAME="999"></A>    <FONT ID="Private">private</FONT> <A HREF="../jminusminus/JExpression.java.html">JExpression</A> assignmentExpression() {
<FONT ID="LN">1000</FONT><A NAME="1000"></A>        <FONT ID="Int">int</FONT> line = scanner.token().line();
<FONT ID="LN">1001</FONT><A NAME="1001"></A>        <A HREF="../jminusminus/JExpression.java.html">JExpression</A> lhs = conditionalAndExpression();
<FONT ID="LN">1002</FONT><A NAME="1002"></A>        <FONT ID="If">if</FONT> (have(ASSIGN)) {
<FONT ID="LN">1003</FONT><A NAME="1003"></A>            <FONT ID="Return">return</FONT> <FONT ID="New">new</FONT> JAssignOp(line, lhs, assignmentExpression());
<FONT ID="LN">1004</FONT><A NAME="1004"></A>        } <FONT ID="Else">else</FONT> <FONT ID="If">if</FONT> (have(PLUS_ASSIGN)) {
<FONT ID="LN">1005</FONT><A NAME="1005"></A>            <FONT ID="Return">return</FONT> <FONT ID="New">new</FONT> JPlusAssignOp(line, lhs, assignmentExpression());
<FONT ID="LN">1006</FONT><A NAME="1006"></A>        } <FONT ID="Else">else</FONT> {
<FONT ID="LN">1007</FONT><A NAME="1007"></A>            <FONT ID="Return">return</FONT> lhs;
<FONT ID="LN">1008</FONT><A NAME="1008"></A>        }
<FONT ID="LN">1009</FONT><A NAME="1009"></A>    }
<FONT ID="LN">1010</FONT><A NAME="1010"></A>
<FONT ID="LN">1011</FONT><A NAME="1011"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">1012</FONT><A NAME="1012"></A>     * Parse a conditional-and expression.
<FONT ID="LN">1013</FONT><A NAME="1013"></A>     * 
<FONT ID="LN">1014</FONT><A NAME="1014"></A>     * &lt;pre&gt;
<FONT ID="LN">1015</FONT><A NAME="1015"></A>     *   conditionalAndExpression ::= equalityExpression // level 10
<FONT ID="LN">1016</FONT><A NAME="1016"></A>     *                                  {LAND equalityExpression}
<FONT ID="LN">1017</FONT><A NAME="1017"></A>     * &lt;/pre&gt;
<FONT ID="LN">1018</FONT><A NAME="1018"></A>     * 
<FONT ID="LN">1019</FONT><A NAME="1019"></A>     * @return an AST for a conditionalExpression.
<FONT ID="LN">1020</FONT><A NAME="1020"></A>     */</FONT>
<FONT ID="LN">1021</FONT><A NAME="1021"></A>
<FONT ID="LN">1022</FONT><A NAME="1022"></A>    <FONT ID="Private">private</FONT> <A HREF="../jminusminus/JExpression.java.html">JExpression</A> conditionalAndExpression() {
<FONT ID="LN">1023</FONT><A NAME="1023"></A>        <FONT ID="Int">int</FONT> line = scanner.token().line();
<FONT ID="LN">1024</FONT><A NAME="1024"></A>        <FONT ID="Boolean">boolean</FONT> more = <FONT ID="True">true</FONT>;
<FONT ID="LN">1025</FONT><A NAME="1025"></A>        <A HREF="../jminusminus/JExpression.java.html">JExpression</A> lhs = equalityExpression();
<FONT ID="LN">1026</FONT><A NAME="1026"></A>        <FONT ID="While">while</FONT> (more) {
<FONT ID="LN">1027</FONT><A NAME="1027"></A>            <FONT ID="If">if</FONT> (have(LAND)) {
<FONT ID="LN">1028</FONT><A NAME="1028"></A>                lhs = <FONT ID="New">new</FONT> JLogicalAndOp(line, lhs, equalityExpression());
<FONT ID="LN">1029</FONT><A NAME="1029"></A>            } <FONT ID="Else">else</FONT> {
<FONT ID="LN">1030</FONT><A NAME="1030"></A>                more = <FONT ID="False">false</FONT>;
<FONT ID="LN">1031</FONT><A NAME="1031"></A>            }
<FONT ID="LN">1032</FONT><A NAME="1032"></A>        }
<FONT ID="LN">1033</FONT><A NAME="1033"></A>        <FONT ID="Return">return</FONT> lhs;
<FONT ID="LN">1034</FONT><A NAME="1034"></A>    }
<FONT ID="LN">1035</FONT><A NAME="1035"></A>
<FONT ID="LN">1036</FONT><A NAME="1036"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">1037</FONT><A NAME="1037"></A>     * Parse an equality expression.
<FONT ID="LN">1038</FONT><A NAME="1038"></A>     * 
<FONT ID="LN">1039</FONT><A NAME="1039"></A>     * &lt;pre&gt;
<FONT ID="LN">1040</FONT><A NAME="1040"></A>     *   equalityExpression ::= relationalExpression  // level 6
<FONT ID="LN">1041</FONT><A NAME="1041"></A>     *                            {EQUAL relationalExpression}
<FONT ID="LN">1042</FONT><A NAME="1042"></A>     * &lt;/pre&gt;
<FONT ID="LN">1043</FONT><A NAME="1043"></A>     * 
<FONT ID="LN">1044</FONT><A NAME="1044"></A>     * @return an AST for an equalityExpression.
<FONT ID="LN">1045</FONT><A NAME="1045"></A>     */</FONT>
<FONT ID="LN">1046</FONT><A NAME="1046"></A>
<FONT ID="LN">1047</FONT><A NAME="1047"></A>    <FONT ID="Private">private</FONT> <A HREF="../jminusminus/JExpression.java.html">JExpression</A> equalityExpression() {
<FONT ID="LN">1048</FONT><A NAME="1048"></A>        <FONT ID="Int">int</FONT> line = scanner.token().line();
<FONT ID="LN">1049</FONT><A NAME="1049"></A>        <FONT ID="Boolean">boolean</FONT> more = <FONT ID="True">true</FONT>;
<FONT ID="LN">1050</FONT><A NAME="1050"></A>        <A HREF="../jminusminus/JExpression.java.html">JExpression</A> lhs = relationalExpression();
<FONT ID="LN">1051</FONT><A NAME="1051"></A>        <FONT ID="While">while</FONT> (more) {
<FONT ID="LN">1052</FONT><A NAME="1052"></A>            <FONT ID="If">if</FONT> (have(EQUAL)) {
<FONT ID="LN">1053</FONT><A NAME="1053"></A>                lhs = <FONT ID="New">new</FONT> JEqualOp(line, lhs, relationalExpression());
<FONT ID="LN">1054</FONT><A NAME="1054"></A>            } <FONT ID="Else">else</FONT> {
<FONT ID="LN">1055</FONT><A NAME="1055"></A>                more = <FONT ID="False">false</FONT>;
<FONT ID="LN">1056</FONT><A NAME="1056"></A>            }
<FONT ID="LN">1057</FONT><A NAME="1057"></A>        }
<FONT ID="LN">1058</FONT><A NAME="1058"></A>        <FONT ID="Return">return</FONT> lhs;
<FONT ID="LN">1059</FONT><A NAME="1059"></A>    }
<FONT ID="LN">1060</FONT><A NAME="1060"></A>
<FONT ID="LN">1061</FONT><A NAME="1061"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">1062</FONT><A NAME="1062"></A>     * Parse a relational expression.
<FONT ID="LN">1063</FONT><A NAME="1063"></A>     * 
<FONT ID="LN">1064</FONT><A NAME="1064"></A>     * &lt;pre&gt;
<FONT ID="LN">1065</FONT><A NAME="1065"></A>     *   relationalExpression ::= additiveExpression  // level 5
<FONT ID="LN">1066</FONT><A NAME="1066"></A>     *                              [(GT | LE) additiveExpression 
<FONT ID="LN">1067</FONT><A NAME="1067"></A>     *                              | INSTANCEOF referenceType]
<FONT ID="LN">1068</FONT><A NAME="1068"></A>     * &lt;/pre&gt;
<FONT ID="LN">1069</FONT><A NAME="1069"></A>     * 
<FONT ID="LN">1070</FONT><A NAME="1070"></A>     * @return an AST for a relationalExpression.
<FONT ID="LN">1071</FONT><A NAME="1071"></A>     */</FONT>
<FONT ID="LN">1072</FONT><A NAME="1072"></A>
<FONT ID="LN">1073</FONT><A NAME="1073"></A>    <FONT ID="Private">private</FONT> <A HREF="../jminusminus/JExpression.java.html">JExpression</A> relationalExpression() {
<FONT ID="LN">1074</FONT><A NAME="1074"></A>        <FONT ID="Int">int</FONT> line = scanner.token().line();
<FONT ID="LN">1075</FONT><A NAME="1075"></A>        <A HREF="../jminusminus/JExpression.java.html">JExpression</A> lhs = additiveExpression();
<FONT ID="LN">1076</FONT><A NAME="1076"></A>        <FONT ID="If">if</FONT> (have(GT)) {
<FONT ID="LN">1077</FONT><A NAME="1077"></A>            <FONT ID="Return">return</FONT> <FONT ID="New">new</FONT> JGreaterThanOp(line, lhs, additiveExpression());
<FONT ID="LN">1078</FONT><A NAME="1078"></A>        } <FONT ID="Else">else</FONT> <FONT ID="If">if</FONT> (have(LE)) {
<FONT ID="LN">1079</FONT><A NAME="1079"></A>            <FONT ID="Return">return</FONT> <FONT ID="New">new</FONT> JLessEqualOp(line, lhs, additiveExpression());
<FONT ID="LN">1080</FONT><A NAME="1080"></A>        } <FONT ID="Else">else</FONT> <FONT ID="If">if</FONT> (have(INSTANCEOF)) {
<FONT ID="LN">1081</FONT><A NAME="1081"></A>            <FONT ID="Return">return</FONT> <FONT ID="New">new</FONT> <A HREF="../jminusminus/JInstanceOfOp.java.html">JInstanceOfOp</A>(line, lhs, referenceType());
<FONT ID="LN">1082</FONT><A NAME="1082"></A>        } <FONT ID="Else">else</FONT> {
<FONT ID="LN">1083</FONT><A NAME="1083"></A>            <FONT ID="Return">return</FONT> lhs;
<FONT ID="LN">1084</FONT><A NAME="1084"></A>        }
<FONT ID="LN">1085</FONT><A NAME="1085"></A>    }
<FONT ID="LN">1086</FONT><A NAME="1086"></A>
<FONT ID="LN">1087</FONT><A NAME="1087"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">1088</FONT><A NAME="1088"></A>     * Parse an additive expression.
<FONT ID="LN">1089</FONT><A NAME="1089"></A>     * 
<FONT ID="LN">1090</FONT><A NAME="1090"></A>     * &lt;pre&gt;
<FONT ID="LN">1091</FONT><A NAME="1091"></A>     *   additiveExpression ::= multiplicativeExpression // level 3
<FONT ID="LN">1092</FONT><A NAME="1092"></A>     *                            {MINUS multiplicativeExpression}
<FONT ID="LN">1093</FONT><A NAME="1093"></A>     * &lt;/pre&gt;
<FONT ID="LN">1094</FONT><A NAME="1094"></A>     * 
<FONT ID="LN">1095</FONT><A NAME="1095"></A>     * @return an AST for an additiveExpression.
<FONT ID="LN">1096</FONT><A NAME="1096"></A>     */</FONT>
<FONT ID="LN">1097</FONT><A NAME="1097"></A>
<FONT ID="LN">1098</FONT><A NAME="1098"></A>    <FONT ID="Private">private</FONT> <A HREF="../jminusminus/JExpression.java.html">JExpression</A> additiveExpression() {
<FONT ID="LN">1099</FONT><A NAME="1099"></A>        <FONT ID="Int">int</FONT> line = scanner.token().line();
<FONT ID="LN">1100</FONT><A NAME="1100"></A>        <FONT ID="Boolean">boolean</FONT> more = <FONT ID="True">true</FONT>;
<FONT ID="LN">1101</FONT><A NAME="1101"></A>        <A HREF="../jminusminus/JExpression.java.html">JExpression</A> lhs = multiplicativeExpression();
<FONT ID="LN">1102</FONT><A NAME="1102"></A>        <FONT ID="While">while</FONT> (more) {
<FONT ID="LN">1103</FONT><A NAME="1103"></A>            <FONT ID="If">if</FONT> (have(MINUS)) {
<FONT ID="LN">1104</FONT><A NAME="1104"></A>                lhs = <FONT ID="New">new</FONT> JSubtractOp(line, lhs, multiplicativeExpression());
<FONT ID="LN">1105</FONT><A NAME="1105"></A>            } <FONT ID="Else">else</FONT> <FONT ID="If">if</FONT> (have(PLUS)) {
<FONT ID="LN">1106</FONT><A NAME="1106"></A>                lhs = <FONT ID="New">new</FONT> JPlusOp(line, lhs, multiplicativeExpression());
<FONT ID="LN">1107</FONT><A NAME="1107"></A>            } <FONT ID="Else">else</FONT> {
<FONT ID="LN">1108</FONT><A NAME="1108"></A>                more = <FONT ID="False">false</FONT>;
<FONT ID="LN">1109</FONT><A NAME="1109"></A>            }
<FONT ID="LN">1110</FONT><A NAME="1110"></A>        }
<FONT ID="LN">1111</FONT><A NAME="1111"></A>        <FONT ID="Return">return</FONT> lhs;
<FONT ID="LN">1112</FONT><A NAME="1112"></A>    }
<FONT ID="LN">1113</FONT><A NAME="1113"></A>
<FONT ID="LN">1114</FONT><A NAME="1114"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">1115</FONT><A NAME="1115"></A>     * Parse a multiplicative expression.
<FONT ID="LN">1116</FONT><A NAME="1116"></A>     * 
<FONT ID="LN">1117</FONT><A NAME="1117"></A>     * &lt;pre&gt;
<FONT ID="LN">1118</FONT><A NAME="1118"></A>     *   multiplicativeExpression ::= unaryExpression  // level 2
<FONT ID="LN">1119</FONT><A NAME="1119"></A>     *                                  {STAR unaryExpression}
<FONT ID="LN">1120</FONT><A NAME="1120"></A>     * &lt;/pre&gt;
<FONT ID="LN">1121</FONT><A NAME="1121"></A>     * 
<FONT ID="LN">1122</FONT><A NAME="1122"></A>     * @return an AST for a multiplicativeExpression.
<FONT ID="LN">1123</FONT><A NAME="1123"></A>     */</FONT>
<FONT ID="LN">1124</FONT><A NAME="1124"></A>
<FONT ID="LN">1125</FONT><A NAME="1125"></A>    <FONT ID="Private">private</FONT> <A HREF="../jminusminus/JExpression.java.html">JExpression</A> multiplicativeExpression() {
<FONT ID="LN">1126</FONT><A NAME="1126"></A>        <FONT ID="Int">int</FONT> line = scanner.token().line();
<FONT ID="LN">1127</FONT><A NAME="1127"></A>        <FONT ID="Boolean">boolean</FONT> more = <FONT ID="True">true</FONT>;
<FONT ID="LN">1128</FONT><A NAME="1128"></A>        <A HREF="../jminusminus/JExpression.java.html">JExpression</A> lhs = unaryExpression();
<FONT ID="LN">1129</FONT><A NAME="1129"></A>        <FONT ID="While">while</FONT> (more) {
<FONT ID="LN">1130</FONT><A NAME="1130"></A>            <FONT ID="If">if</FONT> (have(STAR)) {
<FONT ID="LN">1131</FONT><A NAME="1131"></A>                lhs = <FONT ID="New">new</FONT> JMultiplyOp(line, lhs, unaryExpression());
<FONT ID="LN">1132</FONT><A NAME="1132"></A>            } <FONT ID="Else">else</FONT> {
<FONT ID="LN">1133</FONT><A NAME="1133"></A>                more = <FONT ID="False">false</FONT>;
<FONT ID="LN">1134</FONT><A NAME="1134"></A>            }
<FONT ID="LN">1135</FONT><A NAME="1135"></A>        }
<FONT ID="LN">1136</FONT><A NAME="1136"></A>        <FONT ID="Return">return</FONT> lhs;
<FONT ID="LN">1137</FONT><A NAME="1137"></A>    }
<FONT ID="LN">1138</FONT><A NAME="1138"></A>
<FONT ID="LN">1139</FONT><A NAME="1139"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">1140</FONT><A NAME="1140"></A>     * Parse an unary expression.
<FONT ID="LN">1141</FONT><A NAME="1141"></A>     * 
<FONT ID="LN">1142</FONT><A NAME="1142"></A>     * &lt;pre&gt;
<FONT ID="LN">1143</FONT><A NAME="1143"></A>     *   unaryExpression ::= INC unaryExpression // level 1
<FONT ID="LN">1144</FONT><A NAME="1144"></A>     *                     | MINUS unaryExpression
<FONT ID="LN">1145</FONT><A NAME="1145"></A>     *                     | simpleUnaryExpression
<FONT ID="LN">1146</FONT><A NAME="1146"></A>     * &lt;/pre&gt;
<FONT ID="LN">1147</FONT><A NAME="1147"></A>     * 
<FONT ID="LN">1148</FONT><A NAME="1148"></A>     * @return an AST for an unaryExpression.
<FONT ID="LN">1149</FONT><A NAME="1149"></A>     */</FONT>
<FONT ID="LN">1150</FONT><A NAME="1150"></A>
<FONT ID="LN">1151</FONT><A NAME="1151"></A>    <FONT ID="Private">private</FONT> <A HREF="../jminusminus/JExpression.java.html">JExpression</A> unaryExpression() {
<FONT ID="LN">1152</FONT><A NAME="1152"></A>        <FONT ID="Int">int</FONT> line = scanner.token().line();
<FONT ID="LN">1153</FONT><A NAME="1153"></A>        <FONT ID="If">if</FONT> (have(INC)) {
<FONT ID="LN">1154</FONT><A NAME="1154"></A>            <FONT ID="Return">return</FONT> <FONT ID="New">new</FONT> JPreIncrementOp(line, unaryExpression());
<FONT ID="LN">1155</FONT><A NAME="1155"></A>        } <FONT ID="Else">else</FONT> <FONT ID="If">if</FONT> (have(MINUS)) {
<FONT ID="LN">1156</FONT><A NAME="1156"></A>            <FONT ID="Return">return</FONT> <FONT ID="New">new</FONT> JNegateOp(line, unaryExpression());
<FONT ID="LN">1157</FONT><A NAME="1157"></A>        } <FONT ID="Else">else</FONT> {
<FONT ID="LN">1158</FONT><A NAME="1158"></A>            <FONT ID="Return">return</FONT> simpleUnaryExpression();
<FONT ID="LN">1159</FONT><A NAME="1159"></A>        }
<FONT ID="LN">1160</FONT><A NAME="1160"></A>    }
<FONT ID="LN">1161</FONT><A NAME="1161"></A>
<FONT ID="LN">1162</FONT><A NAME="1162"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">1163</FONT><A NAME="1163"></A>     * Parse a simple unary expression.
<FONT ID="LN">1164</FONT><A NAME="1164"></A>     * 
<FONT ID="LN">1165</FONT><A NAME="1165"></A>     * &lt;pre&gt;
<FONT ID="LN">1166</FONT><A NAME="1166"></A>     *   simpleUnaryExpression ::= LNOT unaryExpression
<FONT ID="LN">1167</FONT><A NAME="1167"></A>     *                           | LPAREN basicType RPAREN 
<FONT ID="LN">1168</FONT><A NAME="1168"></A>     *                               unaryExpression
<FONT ID="LN">1169</FONT><A NAME="1169"></A>     *                           | LPAREN         
<FONT ID="LN">1170</FONT><A NAME="1170"></A>     *                               referenceType
<FONT ID="LN">1171</FONT><A NAME="1171"></A>     *                             RPAREN simpleUnaryExpression
<FONT ID="LN">1172</FONT><A NAME="1172"></A>     *                           | postfixExpression
<FONT ID="LN">1173</FONT><A NAME="1173"></A>     * &lt;/pre&gt;
<FONT ID="LN">1174</FONT><A NAME="1174"></A>     * 
<FONT ID="LN">1175</FONT><A NAME="1175"></A>     * @return an AST for a simpleUnaryExpression.
<FONT ID="LN">1176</FONT><A NAME="1176"></A>     */</FONT>
<FONT ID="LN">1177</FONT><A NAME="1177"></A>
<FONT ID="LN">1178</FONT><A NAME="1178"></A>    <FONT ID="Private">private</FONT> <A HREF="../jminusminus/JExpression.java.html">JExpression</A> simpleUnaryExpression() {
<FONT ID="LN">1179</FONT><A NAME="1179"></A>        <FONT ID="Int">int</FONT> line = scanner.token().line();
<FONT ID="LN">1180</FONT><A NAME="1180"></A>        <FONT ID="If">if</FONT> (have(LNOT)) {
<FONT ID="LN">1181</FONT><A NAME="1181"></A>            <FONT ID="Return">return</FONT> <FONT ID="New">new</FONT> JLogicalNotOp(line, unaryExpression());
<FONT ID="LN">1182</FONT><A NAME="1182"></A>        } <FONT ID="Else">else</FONT> <FONT ID="If">if</FONT> (seeCast()) {
<FONT ID="LN">1183</FONT><A NAME="1183"></A>            mustBe(LPAREN);
<FONT ID="LN">1184</FONT><A NAME="1184"></A>            <FONT ID="Boolean">boolean</FONT> isBasicType = seeBasicType();
<FONT ID="LN">1185</FONT><A NAME="1185"></A>            <A HREF="../jminusminus/Type.java.html">Type</A> type = type();
<FONT ID="LN">1186</FONT><A NAME="1186"></A>            mustBe(RPAREN);
<FONT ID="LN">1187</FONT><A NAME="1187"></A>            <A HREF="../jminusminus/JExpression.java.html">JExpression</A> expr = isBasicType ? unaryExpression()
<FONT ID="LN">1188</FONT><A NAME="1188"></A>                    : simpleUnaryExpression();
<FONT ID="LN">1189</FONT><A NAME="1189"></A>            <FONT ID="Return">return</FONT> <FONT ID="New">new</FONT> <A HREF="../jminusminus/JCastOp.java.html">JCastOp</A>(line, type, expr);
<FONT ID="LN">1190</FONT><A NAME="1190"></A>        } <FONT ID="Else">else</FONT> {
<FONT ID="LN">1191</FONT><A NAME="1191"></A>            <FONT ID="Return">return</FONT> postfixExpression();
<FONT ID="LN">1192</FONT><A NAME="1192"></A>        }
<FONT ID="LN">1193</FONT><A NAME="1193"></A>    }
<FONT ID="LN">1194</FONT><A NAME="1194"></A>
<FONT ID="LN">1195</FONT><A NAME="1195"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">1196</FONT><A NAME="1196"></A>     * Parse a postfix expression.
<FONT ID="LN">1197</FONT><A NAME="1197"></A>     * 
<FONT ID="LN">1198</FONT><A NAME="1198"></A>     * &lt;pre&gt;
<FONT ID="LN">1199</FONT><A NAME="1199"></A>     *   postfixExpression ::= primary {selector} {DEC}
<FONT ID="LN">1200</FONT><A NAME="1200"></A>     * &lt;/pre&gt;
<FONT ID="LN">1201</FONT><A NAME="1201"></A>     * 
<FONT ID="LN">1202</FONT><A NAME="1202"></A>     * @return an AST for a postfixExpression.
<FONT ID="LN">1203</FONT><A NAME="1203"></A>     */</FONT>
<FONT ID="LN">1204</FONT><A NAME="1204"></A>
<FONT ID="LN">1205</FONT><A NAME="1205"></A>    <FONT ID="Private">private</FONT> <A HREF="../jminusminus/JExpression.java.html">JExpression</A> postfixExpression() {
<FONT ID="LN">1206</FONT><A NAME="1206"></A>        <FONT ID="Int">int</FONT> line = scanner.token().line();
<FONT ID="LN">1207</FONT><A NAME="1207"></A>        <A HREF="../jminusminus/JExpression.java.html">JExpression</A> primaryExpr = primary();
<FONT ID="LN">1208</FONT><A NAME="1208"></A>        <FONT ID="While">while</FONT> (see(DOT) || see(LBRACK)) {
<FONT ID="LN">1209</FONT><A NAME="1209"></A>            primaryExpr = selector(primaryExpr);
<FONT ID="LN">1210</FONT><A NAME="1210"></A>        }
<FONT ID="LN">1211</FONT><A NAME="1211"></A>        <FONT ID="While">while</FONT> (have(DEC)) {
<FONT ID="LN">1212</FONT><A NAME="1212"></A>            primaryExpr = <FONT ID="New">new</FONT> JPostDecrementOp(line, primaryExpr);
<FONT ID="LN">1213</FONT><A NAME="1213"></A>        }
<FONT ID="LN">1214</FONT><A NAME="1214"></A>        <FONT ID="Return">return</FONT> primaryExpr;
<FONT ID="LN">1215</FONT><A NAME="1215"></A>    }
<FONT ID="LN">1216</FONT><A NAME="1216"></A>
<FONT ID="LN">1217</FONT><A NAME="1217"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">1218</FONT><A NAME="1218"></A>     * Parse a selector.
<FONT ID="LN">1219</FONT><A NAME="1219"></A>     * 
<FONT ID="LN">1220</FONT><A NAME="1220"></A>     * &lt;pre&gt;
<FONT ID="LN">1221</FONT><A NAME="1221"></A>     *   selector ::= DOT qualifiedIdentifier [arguments]
<FONT ID="LN">1222</FONT><A NAME="1222"></A>     *              | LBRACK expression RBRACK
<FONT ID="LN">1223</FONT><A NAME="1223"></A>     * &lt;/pre&gt;
<FONT ID="LN">1224</FONT><A NAME="1224"></A>     * 
<FONT ID="LN">1225</FONT><A NAME="1225"></A>     * @param target
<FONT ID="LN">1226</FONT><A NAME="1226"></A>     *            the target expression for this selector.
<FONT ID="LN">1227</FONT><A NAME="1227"></A>     * @return an AST for a selector.
<FONT ID="LN">1228</FONT><A NAME="1228"></A>     */</FONT>
<FONT ID="LN">1229</FONT><A NAME="1229"></A>
<FONT ID="LN">1230</FONT><A NAME="1230"></A>    <FONT ID="Private">private</FONT> <A HREF="../jminusminus/JExpression.java.html">JExpression</A> selector(<A HREF="../jminusminus/JExpression.java.html">JExpression</A> target) {
<FONT ID="LN">1231</FONT><A NAME="1231"></A>        <FONT ID="Int">int</FONT> line = scanner.token().line();
<FONT ID="LN">1232</FONT><A NAME="1232"></A>        <FONT ID="If">if</FONT> (have(DOT)) {
<FONT ID="LN">1233</FONT><A NAME="1233"></A>            <FONT ID="SingleLineComment">// Target . selector
<FONT ID="LN">1234</FONT><A NAME="1234"></A></FONT>            mustBe(IDENTIFIER);
<FONT ID="LN">1235</FONT><A NAME="1235"></A>            String name = scanner.previousToken().image();
<FONT ID="LN">1236</FONT><A NAME="1236"></A>            <FONT ID="If">if</FONT> (see(LPAREN)) {
<FONT ID="LN">1237</FONT><A NAME="1237"></A>                ArrayList&lt;<A HREF="../jminusminus/JExpression.java.html">JExpression</A>&gt; args = arguments();
<FONT ID="LN">1238</FONT><A NAME="1238"></A>                <FONT ID="Return">return</FONT> <FONT ID="New">new</FONT> <A HREF="../jminusminus/JMessageExpression.java.html">JMessageExpression</A>(line, target, name, args);
<FONT ID="LN">1239</FONT><A NAME="1239"></A>            } <FONT ID="Else">else</FONT> {
<FONT ID="LN">1240</FONT><A NAME="1240"></A>                <FONT ID="Return">return</FONT> <FONT ID="New">new</FONT> <A HREF="../jminusminus/JFieldSelection.java.html">JFieldSelection</A>(line, target, name);
<FONT ID="LN">1241</FONT><A NAME="1241"></A>            }
<FONT ID="LN">1242</FONT><A NAME="1242"></A>        } <FONT ID="Else">else</FONT> {
<FONT ID="LN">1243</FONT><A NAME="1243"></A>            mustBe(LBRACK);
<FONT ID="LN">1244</FONT><A NAME="1244"></A>            <A HREF="../jminusminus/JExpression.java.html">JExpression</A> index = expression();
<FONT ID="LN">1245</FONT><A NAME="1245"></A>            mustBe(RBRACK);
<FONT ID="LN">1246</FONT><A NAME="1246"></A>            <FONT ID="Return">return</FONT> <FONT ID="New">new</FONT> <A HREF="../jminusminus/JArrayExpression.java.html">JArrayExpression</A>(line, target, index);
<FONT ID="LN">1247</FONT><A NAME="1247"></A>        }
<FONT ID="LN">1248</FONT><A NAME="1248"></A>    }
<FONT ID="LN">1249</FONT><A NAME="1249"></A>
<FONT ID="LN">1250</FONT><A NAME="1250"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">1251</FONT><A NAME="1251"></A>     * Parse a primary expression.
<FONT ID="LN">1252</FONT><A NAME="1252"></A>     * 
<FONT ID="LN">1253</FONT><A NAME="1253"></A>     * &lt;pre&gt;
<FONT ID="LN">1254</FONT><A NAME="1254"></A>     *   primary ::= parExpression
<FONT ID="LN">1255</FONT><A NAME="1255"></A>     *             | THIS [arguments]
<FONT ID="LN">1256</FONT><A NAME="1256"></A>     *             | SUPER ( arguments 
<FONT ID="LN">1257</FONT><A NAME="1257"></A>     *                     | DOT IDENTIFIER [arguments] 
<FONT ID="LN">1258</FONT><A NAME="1258"></A>     *                     )
<FONT ID="LN">1259</FONT><A NAME="1259"></A>     *             | literal
<FONT ID="LN">1260</FONT><A NAME="1260"></A>     *             | NEW creator
<FONT ID="LN">1261</FONT><A NAME="1261"></A>     *             | qualifiedIdentifier [arguments]
<FONT ID="LN">1262</FONT><A NAME="1262"></A>     * &lt;/pre&gt;
<FONT ID="LN">1263</FONT><A NAME="1263"></A>     * 
<FONT ID="LN">1264</FONT><A NAME="1264"></A>     * @return an AST for a primary.
<FONT ID="LN">1265</FONT><A NAME="1265"></A>     */</FONT>
<FONT ID="LN">1266</FONT><A NAME="1266"></A>
<FONT ID="LN">1267</FONT><A NAME="1267"></A>    <FONT ID="Private">private</FONT> <A HREF="../jminusminus/JExpression.java.html">JExpression</A> primary() {
<FONT ID="LN">1268</FONT><A NAME="1268"></A>        <FONT ID="Int">int</FONT> line = scanner.token().line();
<FONT ID="LN">1269</FONT><A NAME="1269"></A>        <FONT ID="If">if</FONT> (see(LPAREN)) {
<FONT ID="LN">1270</FONT><A NAME="1270"></A>            <FONT ID="Return">return</FONT> parExpression();
<FONT ID="LN">1271</FONT><A NAME="1271"></A>        } <FONT ID="Else">else</FONT> <FONT ID="If">if</FONT> (have(THIS)) {
<FONT ID="LN">1272</FONT><A NAME="1272"></A>            <FONT ID="If">if</FONT> (see(LPAREN)) {
<FONT ID="LN">1273</FONT><A NAME="1273"></A>                <FONT ID="Return">return</FONT> <FONT ID="New">new</FONT> <A HREF="../jminusminus/JThisConstruction.java.html">JThisConstruction</A>(line, arguments());
<FONT ID="LN">1274</FONT><A NAME="1274"></A>            } <FONT ID="Else">else</FONT> {
<FONT ID="LN">1275</FONT><A NAME="1275"></A>                <FONT ID="Return">return</FONT> <FONT ID="New">new</FONT> <A HREF="../jminusminus/JThis.java.html">JThis</A>(line);
<FONT ID="LN">1276</FONT><A NAME="1276"></A>            }
<FONT ID="LN">1277</FONT><A NAME="1277"></A>        } <FONT ID="Else">else</FONT> <FONT ID="If">if</FONT> (have(SUPER)) {
<FONT ID="LN">1278</FONT><A NAME="1278"></A>            <FONT ID="If">if</FONT> (!have(DOT)) {
<FONT ID="LN">1279</FONT><A NAME="1279"></A>                <FONT ID="Return">return</FONT> <FONT ID="New">new</FONT> <A HREF="../jminusminus/JSuperConstruction.java.html">JSuperConstruction</A>(line, arguments());
<FONT ID="LN">1280</FONT><A NAME="1280"></A>            } <FONT ID="Else">else</FONT> {
<FONT ID="LN">1281</FONT><A NAME="1281"></A>                mustBe(IDENTIFIER);
<FONT ID="LN">1282</FONT><A NAME="1282"></A>                String name = scanner.previousToken().image();
<FONT ID="LN">1283</FONT><A NAME="1283"></A>                <A HREF="../jminusminus/JExpression.java.html">JExpression</A> newTarget = <FONT ID="New">new</FONT> <A HREF="../jminusminus/JSuper.java.html">JSuper</A>(line);
<FONT ID="LN">1284</FONT><A NAME="1284"></A>                <FONT ID="If">if</FONT> (see(LPAREN)) {
<FONT ID="LN">1285</FONT><A NAME="1285"></A>                    <FONT ID="Return">return</FONT> <FONT ID="New">new</FONT> <A HREF="../jminusminus/JMessageExpression.java.html">JMessageExpression</A>(line, newTarget, <FONT ID="Null">null</FONT>, name,
<FONT ID="LN">1286</FONT><A NAME="1286"></A>                            arguments());
<FONT ID="LN">1287</FONT><A NAME="1287"></A>                } <FONT ID="Else">else</FONT> {
<FONT ID="LN">1288</FONT><A NAME="1288"></A>                    <FONT ID="Return">return</FONT> <FONT ID="New">new</FONT> <A HREF="../jminusminus/JFieldSelection.java.html">JFieldSelection</A>(line, newTarget, name);
<FONT ID="LN">1289</FONT><A NAME="1289"></A>                }
<FONT ID="LN">1290</FONT><A NAME="1290"></A>            }
<FONT ID="LN">1291</FONT><A NAME="1291"></A>        } <FONT ID="Else">else</FONT> <FONT ID="If">if</FONT> (have(NEW)) {
<FONT ID="LN">1292</FONT><A NAME="1292"></A>            <FONT ID="Return">return</FONT> creator();
<FONT ID="LN">1293</FONT><A NAME="1293"></A>        } <FONT ID="Else">else</FONT> <FONT ID="If">if</FONT> (see(IDENTIFIER)) {
<FONT ID="LN">1294</FONT><A NAME="1294"></A>            TypeName id = qualifiedIdentifier();
<FONT ID="LN">1295</FONT><A NAME="1295"></A>            <FONT ID="If">if</FONT> (see(LPAREN)) {
<FONT ID="LN">1296</FONT><A NAME="1296"></A>                <FONT ID="Return">return</FONT> <FONT ID="New">new</FONT> <A HREF="../jminusminus/JMessageExpression.java.html">JMessageExpression</A>(line, <FONT ID="Null">null</FONT>, ambiguousPart(id), id
<FONT ID="LN">1297</FONT><A NAME="1297"></A>                        .simpleName(), arguments());
<FONT ID="LN">1298</FONT><A NAME="1298"></A>            } <FONT ID="Else">else</FONT> <FONT ID="If">if</FONT> (ambiguousPart(id) == <FONT ID="Null">null</FONT>) {
<FONT ID="LN">1299</FONT><A NAME="1299"></A>                <FONT ID="SingleLineComment">// A simple name
<FONT ID="LN">1300</FONT><A NAME="1300"></A></FONT>                <FONT ID="Return">return</FONT> <FONT ID="New">new</FONT> <A HREF="../jminusminus/JVariable.java.html">JVariable</A>(line, id.simpleName());
<FONT ID="LN">1301</FONT><A NAME="1301"></A>            } <FONT ID="Else">else</FONT> {
<FONT ID="LN">1302</FONT><A NAME="1302"></A>                <FONT ID="SingleLineComment">// ambiguousPart.fieldName
<FONT ID="LN">1303</FONT><A NAME="1303"></A></FONT>                <FONT ID="Return">return</FONT> <FONT ID="New">new</FONT> <A HREF="../jminusminus/JFieldSelection.java.html">JFieldSelection</A>(line, ambiguousPart(id), <FONT ID="Null">null</FONT>, id
<FONT ID="LN">1304</FONT><A NAME="1304"></A>                        .simpleName());
<FONT ID="LN">1305</FONT><A NAME="1305"></A>            }
<FONT ID="LN">1306</FONT><A NAME="1306"></A>        } <FONT ID="Else">else</FONT> {
<FONT ID="LN">1307</FONT><A NAME="1307"></A>            <FONT ID="Return">return</FONT> literal();
<FONT ID="LN">1308</FONT><A NAME="1308"></A>        }
<FONT ID="LN">1309</FONT><A NAME="1309"></A>    }
<FONT ID="LN">1310</FONT><A NAME="1310"></A>
<FONT ID="LN">1311</FONT><A NAME="1311"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">1312</FONT><A NAME="1312"></A>     * Parse a creator.
<FONT ID="LN">1313</FONT><A NAME="1313"></A>     * 
<FONT ID="LN">1314</FONT><A NAME="1314"></A>     * &lt;pre&gt;
<FONT ID="LN">1315</FONT><A NAME="1315"></A>     *   creator ::= (basicType | qualifiedIdentifier) 
<FONT ID="LN">1316</FONT><A NAME="1316"></A>     *                 ( arguments
<FONT ID="LN">1317</FONT><A NAME="1317"></A>     *                 | LBRACK RBRACK {LBRACK RBRACK} 
<FONT ID="LN">1318</FONT><A NAME="1318"></A>     *                     [arrayInitializer]
<FONT ID="LN">1319</FONT><A NAME="1319"></A>     *                 | newArrayDeclarator
<FONT ID="LN">1320</FONT><A NAME="1320"></A>     *                 )
<FONT ID="LN">1321</FONT><A NAME="1321"></A>     * &lt;/pre&gt;
<FONT ID="LN">1322</FONT><A NAME="1322"></A>     * 
<FONT ID="LN">1323</FONT><A NAME="1323"></A>     * @return an AST for a creator.
<FONT ID="LN">1324</FONT><A NAME="1324"></A>     */</FONT>
<FONT ID="LN">1325</FONT><A NAME="1325"></A>
<FONT ID="LN">1326</FONT><A NAME="1326"></A>    <FONT ID="Private">private</FONT> <A HREF="../jminusminus/JExpression.java.html">JExpression</A> creator() {
<FONT ID="LN">1327</FONT><A NAME="1327"></A>        <FONT ID="Int">int</FONT> line = scanner.token().line();
<FONT ID="LN">1328</FONT><A NAME="1328"></A>        <A HREF="../jminusminus/Type.java.html">Type</A> type = seeBasicType() ? basicType() : qualifiedIdentifier();
<FONT ID="LN">1329</FONT><A NAME="1329"></A>        <FONT ID="If">if</FONT> (see(LPAREN)) {
<FONT ID="LN">1330</FONT><A NAME="1330"></A>            ArrayList&lt;<A HREF="../jminusminus/JExpression.java.html">JExpression</A>&gt; args = arguments();
<FONT ID="LN">1331</FONT><A NAME="1331"></A>            <FONT ID="Return">return</FONT> <FONT ID="New">new</FONT> <A HREF="../jminusminus/JNewOp.java.html">JNewOp</A>(line, type, args);
<FONT ID="LN">1332</FONT><A NAME="1332"></A>        } <FONT ID="Else">else</FONT> <FONT ID="If">if</FONT> (see(LBRACK)) {
<FONT ID="LN">1333</FONT><A NAME="1333"></A>            <FONT ID="If">if</FONT> (seeDims()) {
<FONT ID="LN">1334</FONT><A NAME="1334"></A>                <A HREF="../jminusminus/Type.java.html">Type</A> expected = type;
<FONT ID="LN">1335</FONT><A NAME="1335"></A>                <FONT ID="While">while</FONT> (have(LBRACK)) {
<FONT ID="LN">1336</FONT><A NAME="1336"></A>                    mustBe(RBRACK);
<FONT ID="LN">1337</FONT><A NAME="1337"></A>                    expected = <FONT ID="New">new</FONT> ArrayTypeName(expected);
<FONT ID="LN">1338</FONT><A NAME="1338"></A>                }
<FONT ID="LN">1339</FONT><A NAME="1339"></A>                <FONT ID="Return">return</FONT> arrayInitializer(expected);
<FONT ID="LN">1340</FONT><A NAME="1340"></A>            } <FONT ID="Else">else</FONT>
<FONT ID="LN">1341</FONT><A NAME="1341"></A>                <FONT ID="Return">return</FONT> newArrayDeclarator(line, type);
<FONT ID="LN">1342</FONT><A NAME="1342"></A>        } <FONT ID="Else">else</FONT> {
<FONT ID="LN">1343</FONT><A NAME="1343"></A>            reportParserError(<FONT ID="StringLiteral">"( or [ sought where %s found"</FONT>, scanner.token()
<FONT ID="LN">1344</FONT><A NAME="1344"></A>                    .image());
<FONT ID="LN">1345</FONT><A NAME="1345"></A>            <FONT ID="Return">return</FONT> <FONT ID="New">new</FONT> <A HREF="../jminusminus/JWildExpression.java.html">JWildExpression</A>(line);
<FONT ID="LN">1346</FONT><A NAME="1346"></A>        }
<FONT ID="LN">1347</FONT><A NAME="1347"></A>    }
<FONT ID="LN">1348</FONT><A NAME="1348"></A>
<FONT ID="LN">1349</FONT><A NAME="1349"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">1350</FONT><A NAME="1350"></A>     * Parse a new array declarator.
<FONT ID="LN">1351</FONT><A NAME="1351"></A>     * 
<FONT ID="LN">1352</FONT><A NAME="1352"></A>     * &lt;pre&gt;
<FONT ID="LN">1353</FONT><A NAME="1353"></A>     *   newArrayDeclarator ::= LBRACK expression RBRACK 
<FONT ID="LN">1354</FONT><A NAME="1354"></A>     *                            {LBRACK expression RBRACK}
<FONT ID="LN">1355</FONT><A NAME="1355"></A>     *                            {LBRACK RBRACK}
<FONT ID="LN">1356</FONT><A NAME="1356"></A>     * &lt;/pre&gt;
<FONT ID="LN">1357</FONT><A NAME="1357"></A>     * 
<FONT ID="LN">1358</FONT><A NAME="1358"></A>     * @param line
<FONT ID="LN">1359</FONT><A NAME="1359"></A>     *            line in which the declarator occurred.
<FONT ID="LN">1360</FONT><A NAME="1360"></A>     * @param type
<FONT ID="LN">1361</FONT><A NAME="1361"></A>     *            type of the array.
<FONT ID="LN">1362</FONT><A NAME="1362"></A>     * @return an AST for a newArrayDeclarator.
<FONT ID="LN">1363</FONT><A NAME="1363"></A>     */</FONT>
<FONT ID="LN">1364</FONT><A NAME="1364"></A>
<FONT ID="LN">1365</FONT><A NAME="1365"></A>    <FONT ID="Private">private</FONT> <A HREF="../jminusminus/JNewArrayOp.java.html">JNewArrayOp</A> newArrayDeclarator(<FONT ID="Int">int</FONT> line, <A HREF="../jminusminus/Type.java.html">Type</A> type) {
<FONT ID="LN">1366</FONT><A NAME="1366"></A>        ArrayList&lt;<A HREF="../jminusminus/JExpression.java.html">JExpression</A>&gt; dimensions = <FONT ID="New">new</FONT> ArrayList&lt;<A HREF="../jminusminus/JExpression.java.html">JExpression</A>&gt;();
<FONT ID="LN">1367</FONT><A NAME="1367"></A>        mustBe(LBRACK);
<FONT ID="LN">1368</FONT><A NAME="1368"></A>        dimensions.add(expression());
<FONT ID="LN">1369</FONT><A NAME="1369"></A>        mustBe(RBRACK);
<FONT ID="LN">1370</FONT><A NAME="1370"></A>        type = <FONT ID="New">new</FONT> ArrayTypeName(type);
<FONT ID="LN">1371</FONT><A NAME="1371"></A>        <FONT ID="While">while</FONT> (have(LBRACK)) {
<FONT ID="LN">1372</FONT><A NAME="1372"></A>            <FONT ID="If">if</FONT> (have(RBRACK)) {
<FONT ID="LN">1373</FONT><A NAME="1373"></A>                <FONT ID="SingleLineComment">// We're done with dimension expressions
<FONT ID="LN">1374</FONT><A NAME="1374"></A></FONT>                type = <FONT ID="New">new</FONT> ArrayTypeName(type);
<FONT ID="LN">1375</FONT><A NAME="1375"></A>                <FONT ID="While">while</FONT> (have(LBRACK)) {
<FONT ID="LN">1376</FONT><A NAME="1376"></A>                    mustBe(RBRACK);
<FONT ID="LN">1377</FONT><A NAME="1377"></A>                    type = <FONT ID="New">new</FONT> ArrayTypeName(type);
<FONT ID="LN">1378</FONT><A NAME="1378"></A>                }
<FONT ID="LN">1379</FONT><A NAME="1379"></A>                <FONT ID="Return">return</FONT> <FONT ID="New">new</FONT> <A HREF="../jminusminus/JNewArrayOp.java.html">JNewArrayOp</A>(line, type, dimensions);
<FONT ID="LN">1380</FONT><A NAME="1380"></A>            } <FONT ID="Else">else</FONT> {
<FONT ID="LN">1381</FONT><A NAME="1381"></A>                dimensions.add(expression());
<FONT ID="LN">1382</FONT><A NAME="1382"></A>                type = <FONT ID="New">new</FONT> ArrayTypeName(type);
<FONT ID="LN">1383</FONT><A NAME="1383"></A>                mustBe(RBRACK);
<FONT ID="LN">1384</FONT><A NAME="1384"></A>            }
<FONT ID="LN">1385</FONT><A NAME="1385"></A>        }
<FONT ID="LN">1386</FONT><A NAME="1386"></A>        <FONT ID="Return">return</FONT> <FONT ID="New">new</FONT> <A HREF="../jminusminus/JNewArrayOp.java.html">JNewArrayOp</A>(line, type, dimensions);
<FONT ID="LN">1387</FONT><A NAME="1387"></A>    }
<FONT ID="LN">1388</FONT><A NAME="1388"></A>
<FONT ID="LN">1389</FONT><A NAME="1389"></A>    <FONT ID="FormalComment">/**
<FONT ID="LN">1390</FONT><A NAME="1390"></A>     * Parse a literal.
<FONT ID="LN">1391</FONT><A NAME="1391"></A>     * 
<FONT ID="LN">1392</FONT><A NAME="1392"></A>     * &lt;pre&gt;
<FONT ID="LN">1393</FONT><A NAME="1393"></A>     *   literal ::= INT_LITERAL | CHAR_LITERAL | STRING_LITERAL
<FONT ID="LN">1394</FONT><A NAME="1394"></A>     *             | TRUE        | FALSE        | NULL
<FONT ID="LN">1395</FONT><A NAME="1395"></A>     * &lt;/pre&gt;
<FONT ID="LN">1396</FONT><A NAME="1396"></A>     * 
<FONT ID="LN">1397</FONT><A NAME="1397"></A>     * @return an AST for a literal.
<FONT ID="LN">1398</FONT><A NAME="1398"></A>     */</FONT>
<FONT ID="LN">1399</FONT><A NAME="1399"></A>
<FONT ID="LN">1400</FONT><A NAME="1400"></A>    <FONT ID="Private">private</FONT> <A HREF="../jminusminus/JExpression.java.html">JExpression</A> literal() {
<FONT ID="LN">1401</FONT><A NAME="1401"></A>        <FONT ID="Int">int</FONT> line = scanner.token().line();
<FONT ID="LN">1402</FONT><A NAME="1402"></A>        <FONT ID="If">if</FONT> (have(INT_LITERAL)) {
<FONT ID="LN">1403</FONT><A NAME="1403"></A>            <FONT ID="Return">return</FONT> <FONT ID="New">new</FONT> <A HREF="../jminusminus/JLiteralInt.java.html">JLiteralInt</A>(line, scanner.previousToken().image());
<FONT ID="LN">1404</FONT><A NAME="1404"></A>        } <FONT ID="Else">else</FONT> <FONT ID="If">if</FONT> (have(CHAR_LITERAL)) {
<FONT ID="LN">1405</FONT><A NAME="1405"></A>            <FONT ID="Return">return</FONT> <FONT ID="New">new</FONT> <A HREF="../jminusminus/JLiteralChar.java.html">JLiteralChar</A>(line, scanner.previousToken().image());
<FONT ID="LN">1406</FONT><A NAME="1406"></A>        } <FONT ID="Else">else</FONT> <FONT ID="If">if</FONT> (have(STRING_LITERAL)) {
<FONT ID="LN">1407</FONT><A NAME="1407"></A>            <FONT ID="Return">return</FONT> <FONT ID="New">new</FONT> <A HREF="../jminusminus/JLiteralString.java.html">JLiteralString</A>(line, scanner.previousToken().image());
<FONT ID="LN">1408</FONT><A NAME="1408"></A>        } <FONT ID="Else">else</FONT> <FONT ID="If">if</FONT> (have(TRUE)) {
<FONT ID="LN">1409</FONT><A NAME="1409"></A>            <FONT ID="Return">return</FONT> <FONT ID="New">new</FONT> <A HREF="../jminusminus/JLiteralTrue.java.html">JLiteralTrue</A>(line);
<FONT ID="LN">1410</FONT><A NAME="1410"></A>        } <FONT ID="Else">else</FONT> <FONT ID="If">if</FONT> (have(FALSE)) {
<FONT ID="LN">1411</FONT><A NAME="1411"></A>            <FONT ID="Return">return</FONT> <FONT ID="New">new</FONT> <A HREF="../jminusminus/JLiteralFalse.java.html">JLiteralFalse</A>(line);
<FONT ID="LN">1412</FONT><A NAME="1412"></A>        } <FONT ID="Else">else</FONT> <FONT ID="If">if</FONT> (have(NULL)) {
<FONT ID="LN">1413</FONT><A NAME="1413"></A>            <FONT ID="Return">return</FONT> <FONT ID="New">new</FONT> <A HREF="../jminusminus/JLiteralNull.java.html">JLiteralNull</A>(line);
<FONT ID="LN">1414</FONT><A NAME="1414"></A>        } <FONT ID="Else">else</FONT> {
<FONT ID="LN">1415</FONT><A NAME="1415"></A>            reportParserError(<FONT ID="StringLiteral">"Literal sought where %s found"</FONT>, scanner.token()
<FONT ID="LN">1416</FONT><A NAME="1416"></A>                    .image());
<FONT ID="LN">1417</FONT><A NAME="1417"></A>            <FONT ID="Return">return</FONT> <FONT ID="New">new</FONT> <A HREF="../jminusminus/JWildExpression.java.html">JWildExpression</A>(line);
<FONT ID="LN">1418</FONT><A NAME="1418"></A>        }
<FONT ID="LN">1419</FONT><A NAME="1419"></A>    }
<FONT ID="LN">1420</FONT><A NAME="1420"></A>
<FONT ID="LN">1421</FONT><A NAME="1421"></A>    <FONT ID="SingleLineComment">// /**
<FONT ID="LN">1422</FONT><A NAME="1422"></A></FONT>    <FONT ID="SingleLineComment">// * A tracing aid. Invoke to debug the parser at various
<FONT ID="LN">1423</FONT><A NAME="1423"></A></FONT>    <FONT ID="SingleLineComment">// points.
<FONT ID="LN">1424</FONT><A NAME="1424"></A></FONT>    <FONT ID="SingleLineComment">// *
<FONT ID="LN">1425</FONT><A NAME="1425"></A></FONT>    <FONT ID="SingleLineComment">// * @param message for identifying the location of the
<FONT ID="LN">1426</FONT><A NAME="1426"></A></FONT>    <FONT ID="SingleLineComment">// invocation.
<FONT ID="LN">1427</FONT><A NAME="1427"></A></FONT>    <FONT ID="SingleLineComment">// */
<FONT ID="LN">1428</FONT><A NAME="1428"></A></FONT>    <FONT ID="SingleLineComment">//
<FONT ID="LN">1429</FONT><A NAME="1429"></A></FONT>    <FONT ID="SingleLineComment">// private void trace( String message )
<FONT ID="LN">1430</FONT><A NAME="1430"></A></FONT>    <FONT ID="SingleLineComment">// {
<FONT ID="LN">1431</FONT><A NAME="1431"></A></FONT>    <FONT ID="SingleLineComment">// System.err.println( "["
<FONT ID="LN">1432</FONT><A NAME="1432"></A></FONT>    <FONT ID="SingleLineComment">// + scanner.token().line()
<FONT ID="LN">1433</FONT><A NAME="1433"></A></FONT>    <FONT ID="SingleLineComment">// + ": "
<FONT ID="LN">1434</FONT><A NAME="1434"></A></FONT>    <FONT ID="SingleLineComment">// + message
<FONT ID="LN">1435</FONT><A NAME="1435"></A></FONT>    <FONT ID="SingleLineComment">// + ", looking at a: "
<FONT ID="LN">1436</FONT><A NAME="1436"></A></FONT>    <FONT ID="SingleLineComment">// + scanner.token().tokenRep()
<FONT ID="LN">1437</FONT><A NAME="1437"></A></FONT>    <FONT ID="SingleLineComment">// + " = " + scanner.token().image() + "]" );
<FONT ID="LN">1438</FONT><A NAME="1438"></A></FONT>    <FONT ID="SingleLineComment">// }
<FONT ID="LN">1439</FONT><A NAME="1439"></A></FONT>
<FONT ID="LN">1440</FONT><A NAME="1440"></A>}
<FONT ID="LN">1441</FONT><A NAME="1441"></A></pre>
</BODY>
</HTML>